[webkit-dev] Code Style: Opinion on returning void

Chris Dumez cdumez at apple.com
Wed Feb 20 08:42:31 PST 2019


> On Feb 20, 2019, at 7:48 AM, Daniel Bates <dbates at webkit.org> wrote:
> 
> Okay, you’ve changed your mind from your earlier email of not having a strong opinion. Would have been good to know from the get-go. Better late than never knowing :/

I did not change my mind. I said I was using this pattern in my code. So did other people. If we use it in our code, it is because we prefer it.
What I meant to say is that if a majority of people felt strongly that we should not allow this pattern, then I would not stand in the way.

I don’t think this mail thread showed that people strongly feel that we should not allow this pattern. Therefore, I was also surprised by your email saying that we’d reached a consensus.

> 
> Dan
> 
> On Feb 20, 2019, at 6:58 AM, Chris Dumez <cdumez at apple.com <mailto:cdumez at apple.com>> wrote:
> 
>> I also prefer allowed returning void. 
>> 
>> Chris Dumez
>> 
>> On Feb 19, 2019, at 10:35 PM, Daniel Bates <dbates at webkit.org <mailto:dbates at webkit.org>> wrote:
>> 
>>> 
>>> 
>>> On Feb 19, 2019, at 9:42 PM, Ryosuke Niwa <rniwa at webkit.org <mailto:rniwa at webkit.org>> wrote:
>>> 
>>>> On Tue, Feb 19, 2019 at 8:59 PM Daniel Bates <dbates at webkit.org <mailto:dbates at webkit.org>> wrote:
>>>> > On Feb 7, 2019, at 12:47 PM, Daniel Bates <dbates at webkit.org <mailto:dbates at webkit.org>> wrote:
>>>> >
>>>> > Hi all,
>>>> >
>>>> > Something bothers me about code like:
>>>> >
>>>> > void f();
>>>> > void g()
>>>> > {
>>>> >     if (...)
>>>> >         return f();
>>>> >     return f();
>>>> > }
>>>> >
>>>> > I prefer:
>>>> >
>>>> > void g()
>>>> > {
>>>> >     if (...) {
>>>> >         f();
>>>> >         return
>>>> >     }
>>>> >     f();
>>>> > }
>>>> >
>>>> Based on the responses it seems there is sufficient leaning to codify
>>>> the latter style.
>>>> 
>>>> I don't think there is a sufficient consensus as far as I can tell. Geoff
>>> 
>>> I didn't get this from Geoff's remark. Geoff wrote:
>>> 
>>> ***“return f()” when f returns void is a bit mind bending.***
>>> Don't want to put words in Geoff's mouth. So, Geoff can you please confirm: for the former style, for the latter style, no strong opinion.
>>> 
>>>> and Alex both expressed preferences for being able to return void,
>>> 
>>> I got this from Alex's message
>>> 
>>>> and Saam pointed out that there is a lot of existing code which does this.
>>> 
>>> I did not get this. He wrote emphasis mine:
>>> 
>>> I've definitely done this in JSC. ***I don't think it's super common***, but I've also seen code in JSC not written by me that also does this.
>>> 
>>>> Zalan also said he does this in his layout code.
>>> 
>>> I did not get this, quoting, emphasis mine:
>>> 
>>> I use this idiom too in the layout code. I guess I just prefer a more
>>> compact code.
>>> ***(I don't feel too strongly about it though)***
>>> 
>>> By the way, you even acknowledged that "WebKit ... tend[s] to have a separate return.". So, I inferred you were okay with it. But from this email I am no longer sure what your position is. Please state it clearly.
>>> 
>>>> - R. Niwa
>>>> 
>>> _______________________________________________
>>> webkit-dev mailing list
>>> webkit-dev at lists.webkit.org <mailto:webkit-dev at lists.webkit.org>
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev <https://lists.webkit.org/mailman/listinfo/webkit-dev>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20190220/fa2880a8/attachment.html>


More information about the webkit-dev mailing list