Re: [webkit-dev] Code Style: Opinion on returning void
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 Bujtas wrote: > > 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 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, Geoffrey Garen wrote: >> > >> > 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 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(); >> >> } >> >> >> >> Does it bother you? For the former? For the latter? Update our style >> >> guide? >> >> >> >> Opinions, please. >> >> >> >> Dan >> >> ___ >> >> webkit-dev mailing list >> >> webkit-dev@lists.webkit.org >> >> https://lists.webkit.org/mailman/listinfo/webkit-dev >> > >> > ___ >> > webkit-dev mailing list >> > webkit-dev@lists.webkit.org >> > https://lists.webkit.org/mailman/listinfo/webkit-dev >> >> ___ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> https://lists.webkit.org/mailman/listinfo/webkit-dev > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
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 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, Geoffrey Garen wrote: > > > > 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 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(); > >> } > >> > >> Does it bother you? For the former? For the latter? Update our style > guide? > >> > >> Opinions, please. > >> > >> Dan > >> ___ > >> webkit-dev mailing list > >> webkit-dev@lists.webkit.org > >> https://lists.webkit.org/mailman/listinfo/webkit-dev > > > > ___ > > webkit-dev mailing list > > webkit-dev@lists.webkit.org > > https://lists.webkit.org/mailman/listinfo/webkit-dev > > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev > ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
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, Geoffrey Garen wrote: > > 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 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(); >> } >> >> Does it bother you? For the former? For the latter? Update our style guide? >> >> Opinions, please. >> >> Dan >> ___ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> https://lists.webkit.org/mailman/listinfo/webkit-dev > > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
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 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(); > } > > Does it bother you? For the former? For the latter? Update our style guide? > > Opinions, please. > > Dan > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
> 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 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. - Saam > >> I prefer: >> >> void g() >> { >>if (...) { >>f(); >>return >>} >>f(); >> } >> >> Does it bother you? For the former? For the latter? Update our style guide? > > +1 to a style guide update > >> Opinions, please. >> >> Dan >> ___ >> webkit-dev mailing list >> webkit-dev@lists.webkit.org >> https://lists.webkit.org/mailman/listinfo/webkit-dev > > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
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 this‽ > I much prefer doing this in my own code but stay away from it in WebKit because we tend to have a separate return. > I prefer: > > > > void g() > > { > > if (...) { > > f(); > > return > > } > > f(); > > } > > > > Does it bother you? For the former? For the latter? Update our style > guide? > > +1 to a style guide update > Yeah, we might as well as codify it in the style guideline for clarity. - R. Niwa ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Code Style: Opinion on returning void
> 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(); > return > } > f(); > } > > Does it bother you? For the former? For the latter? Update our style guide? +1 to a style guide update > Opinions, please. > > Dan > ___ > webkit-dev mailing list > webkit-dev@lists.webkit.org > https://lists.webkit.org/mailman/listinfo/webkit-dev ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
[webkit-dev] Code Style: Opinion on returning void
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(); } Does it bother you? For the former? For the latter? Update our style guide? Opinions, please. Dan ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev