[Webkit-unassigned] [Bug 225817] Proposed change to WebKit Code Style Guidelines for if-return-else-return

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri May 14 11:04:51 PDT 2021


https://bugs.webkit.org/show_bug.cgi?id=225817

--- Comment #1 from Chris Dumez <cdumez at apple.com> ---
I did run into this recently when introducing an "if constexpr" and had to ignore the rule then. That said, unless forced to by constexpr, I actually like that not using an else statement reduces the nesting. It is the same reason we like early returns in WebKit.

I think this would look terrible for e.g.:
```
if (myEarlyReturnCondition)
    return;
else {
    // My
    // long
    // function
    // body.
}
```

For single line conditions, the having the else statement doesn't look bad but I don't find it more pleasing to have the else statement :)

I also personally don't find it confusing or harder to follow-up that we don't have an else after an early return.

Anyway, if others disagree with me fine but my 2 cents is that I prefer the current coding style (except in the very specific case of if constexpr where we don't have any other choice).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210514/f41c4538/attachment-0001.htm>


More information about the webkit-unassigned mailing list