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

2019-03-20 Thread Nico Weber
On Thu, Feb 21, 2019 at 12:31 PM Darin Adler wrote: > I tried not to weigh in on this, but my view on the materials we should > use to build the bike shed must be shared! > > Generally it seems neat to be able to make the code slightly more tight > and terse by merging the function call and the

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

2019-02-21 Thread Ryosuke Niwa
On Thu, Feb 21, 2019 at 9:31 AM Darin Adler wrote: > I tried not to weigh in on this, but my view on the materials we should > use to build the bike shed must be shared! > > Generally it seems neat to be able to make the code slightly more tight > and terse by merging the function call and the

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

2019-02-21 Thread Darin Adler
I tried not to weigh in on this, but my view on the materials we should use to build the bike shed must be shared! Generally it seems neat to be able to make the code slightly more tight and terse by merging the function call and the return into a single statement. Other than not being

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

2019-02-20 Thread Alex Christensen
I like it mostly for its brevity, but I also think it would be strange that changing a return type from bool to void or vice versa would require touching all its call sites. > On Feb 20, 2019, at 1:20 PM, Chris Dumez wrote: > >> >> On Feb 20, 2019, at 1:14 PM, Maciej Stachowiak >

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

2019-02-20 Thread Chris Dumez
> On Feb 20, 2019, at 1:14 PM, Maciej Stachowiak wrote: > > > It seems like `return foo();` where foo() is a void function can always be > replaced with `foo(); return;` for greater clarity at the cost of one extra > line break. For people who prefer the one-line style, can you say why you

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

2019-02-20 Thread Maciej Stachowiak
It seems like `return foo();` where foo() is a void function can always be replaced with `foo(); return;` for greater clarity at the cost of one extra line break. For people who prefer the one-line style, can you say why you don’t like the other way? - Maciej > On Feb 20, 2019, at 10:33 AM,

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

2019-02-20 Thread Michael Catanzaro
On Wed, Feb 20, 2019 at 12:33 PM, Simon Fraser wrote: I find it mind bending. It makes me wonder if the author made a coding error. Yeah me too. It does seem to work nicely in Alex's CompletionHandler example, but still, I'd just add braces and return on an extra line if I was writing it.

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

2019-02-20 Thread Said Abou-Hallawa
> On Feb 20, 2019, at 10:35 AM, Mark Lam wrote: > > I also prefer it, and I think some coding patterns may require it e.g. in > templates where sometimes we want to specialize into a void function, and > other times into a function that returns a value. However, this is rarely > needed in

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

2019-02-20 Thread Mark Lam
I also prefer it, and I think some coding patterns may require it e.g. in templates where sometimes we want to specialize into a void function, and other times into a function that returns a value. However, this is rarely needed in practice. Without being able to return void, writing such a

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

2019-02-20 Thread Simon Fraser
I find it mind bending. It makes me wonder if the author made a coding error. Simon > On Feb 20, 2019, at 7:48 AM, Daniel Bates wrote: > > Thanks for the opinion! > > Dan > > On Feb 20, 2019, at 7:26 AM, Saam Barati > wrote: > >> I prefer it as well. >> >> - Saam

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

2019-02-20 Thread Chris Dumez
> On Feb 20, 2019, at 7:48 AM, Daniel Bates 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

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

2019-02-20 Thread Saam Barati
I prefer it as well. - Saam > On Feb 20, 2019, at 6:58 AM, Chris Dumez wrote: > > I also prefer allowed returning void. > > Chris Dumez > >> On Feb 19, 2019, at 10:35 PM, Daniel Bates wrote: >> >> >> >>> On Feb 19, 2019, at 9:42 PM, Ryosuke Niwa wrote: >>> On Tue, Feb 19, 2019 at

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

2019-02-20 Thread Chris Dumez
I also prefer allowed returning void. Chris Dumez > On Feb 19, 2019, at 10:35 PM, Daniel Bates wrote: > > > >> On Feb 19, 2019, at 9:42 PM, Ryosuke Niwa wrote: >> >>> On Tue, Feb 19, 2019 at 8:59 PM Daniel Bates wrote: >> >>> > On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: >>> > >>>

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

2019-02-19 Thread Daniel Bates
On Feb 19, 2019, at 9:42 PM, Ryosuke Niwa wrote: On Tue, Feb 19, 2019 at 8:59 PM Daniel Bates wrote: > > On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: > > > > Hi all, > > > > Something bothers me about code like: > > > > void f(); > > void g() > > { > > if (...) > > return f();

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

2019-02-19 Thread Ryosuke Niwa
On Tue, Feb 19, 2019 at 8:59 PM Daniel Bates wrote: > > On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: > > > > Hi all, > > > > Something bothers me about code like: > > > > void f(); > > void g() > > { > > if (...) > > return f(); > > return f(); > > } > > > > I prefer: > > >

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

2019-02-19 Thread Daniel Bates
> On Feb 7, 2019, at 12:47 PM, Daniel Bates 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(); > } >

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

2019-02-13 Thread Keith Miller
I’ve definitely done this in JSC before. As with everyone else, I don’t feel particularly strongly about it. > On Feb 7, 2019, at 8:45 PM, Chris Dumez wrote: > > Same here, I used it in PSON code with completion handlers. I liked the more > concise code but I also do not feel strongly about

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

2019-02-07 Thread Chris Dumez
Same here, I used it in PSON code with completion handlers. I liked the more concise code but I also do not feel strongly about it. The extra return line often would have meant adding curly brackets for if statements leading to early returns. Chris Dumez > On Feb 7, 2019, at 8:23 PM, Zalan

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

2019-02-07 Thread Zalan Bujtas
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) Alan. On Thu, Feb 7, 2019 at 7:31 PM Alex Christensen wrote: > If you search for “return completionHandler” in WebKit you will find over > a hundred instances. Most

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

2019-02-07 Thread Alex Christensen
If you search for “return completionHandler” in WebKit you will find over a hundred instances. Most if not all of them return void. It means call the completion handler and return. I probably wrote most of them and obviously think it’s a fabulous idiom. > On Feb 7, 2019, at 2:32 PM,

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

2019-02-07 Thread Geoffrey Garen
FWIW, I’ve always felt conflicted about this case. I very much prefer early return to if/else chains. However, “return f()” when f returns void is a bit mind bending. So, I can’t use my preferred style in functions that return void. Boo. Geoff > On Feb 7, 2019, at 12:47 PM, Daniel Bates

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

2019-02-07 Thread Saam Barati
> On Feb 7, 2019, at 12:53 PM, Tim Horton wrote: > > > >> On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: >> >> Hi all, >> >> Something bothers me about code like: >> >> void f(); >> void g() >> { >>if (...) >>return f(); >>return f(); >> } > > ⸘do people do this‽ I've

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

2019-02-07 Thread Ryosuke Niwa
On Thu, Feb 7, 2019 at 12:53 PM Tim Horton wrote: > > > > On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: > > > > Hi all, > > > > Something bothers me about code like: > > > > void f(); > > void g() > > { > > if (...) > > return f(); > > return f(); > > } > > ⸘do people do

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

2019-02-07 Thread Tim Horton
> On Feb 7, 2019, at 12:47 PM, Daniel Bates wrote: > > Hi all, > > Something bothers me about code like: > > void f(); > void g() > { > if (...) > return f(); > return f(); > } ⸘do people do this‽ > I prefer: > > void g() > { > if (...) { > f(); >