JavaScript Concern from a recent review
Myk Melez
myk at mozilla.org
Mon Apr 9 15:08:19 UTC 2007
Dave Williss wrote:
> Where I work, our code style guidelines actually *require* braces in
> this case. The only time we don't require them is if the whole thing
> is on one line.
FWIW, in another nit in the same review, I suggest not putting the block
on the same line as the condition, i.e.:
>+ if (phase < 1 && phase > 2) return false;
Nit: block on a new line here and elsewhere:
if (phase < 1 && phase > 2)
return false;
> This is for C/C++ code, but it applies to just about any language
> which uses braces. In fact, if I'm not mistaken, in Perl it's
> actually invalid syntax to omit them.
Right, except with statement modifiers.
FWIW, I do think braces are justified for certain one-line blocks, like
where there are nested elses. I just don't think they help more than
they hurt in the general case.
But this seems to be a matter of opinion, and Dave says he wants braces,
so nit revoked.
-myk
More information about the developers
mailing list