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

Ryosuke Niwa rniwa at webkit.org
Thu Feb 7 13:35:35 PST 2019


On Thu, Feb 7, 2019 at 12:53 PM Tim Horton <timothy_horton at apple.com> wrote:

>
>
> > On Feb 7, 2019, at 12:47 PM, Daniel Bates <dbates at webkit.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20190207/3af584e7/attachment.html>


More information about the webkit-dev mailing list