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

Ryosuke Niwa rniwa at webkit.org
Tue Feb 19 21:42:56 PST 2019


On Tue, Feb 19, 2019 at 8:59 PM Daniel Bates <dbates at webkit.org> 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();
> > }
> >
> > 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
and Alex both expressed preferences for being able to return void, and Saam
pointed out that there is a lot of existing code which does this. Zalan
also said he does this in his layout code.

- R. Niwa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20190219/2cfe587c/attachment.html>


More information about the webkit-dev mailing list