Which is preferred? for (...; ...; ...) { } or for (...; ...; ...) { }
Option 1 Seems in keeping with what is done for constructors/functions w/o bodies, so for consistency, I think it it preferable. On Thu, Aug 26, 2010 at 11:35 AM, Chris Fleizach <cfleizach@apple.com>wrote:
Which is preferred?
for (...; ...; ...) { }
or
for (...; ...; ...) { }
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
On Aug 26, 2010, at 11:35 AM, Chris Fleizach wrote:
for (...; ...; ...) { }
This seems OK.
for (...; ...; ...) { }
The above is definitely not allowed, because braces go on the line with the "for". The other possibilities are: C) for (...) ; D) for (...) { } E) for (...) { // intentionally-empty loop body. } I would probably use (C) in code I was writing. This doesn’t come up much. -- Darin
On Thu, Aug 26, 2010 at 11:49 AM, Darin Adler <darin@apple.com> wrote:
On Aug 26, 2010, at 11:35 AM, Chris Fleizach wrote:
for (...; ...; ...) { }
This seems OK.
for (...; ...; ...) { }
The above is definitely not allowed, because braces go on the line with the "for".
The other possibilities are:
C) for (...) ;
D) for (...) { }
E) for (...) { // intentionally-empty loop body. }
I would probably use (C) in code I was writing. This doesn’t come up much.
FWIW, clang warns about (C) but doesn't warn about the others (at least on high warning levels). Nico
-- Darin
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
The style guide currently covers this http://webkit.org/coding/coding-style.html: 4. Control clauses without a body should use empty braces:Right: for ( ; current; current = current->next) { } Wrong: for ( ; current; current = current->next); - James On Thu, Aug 26, 2010 at 12:22 PM, Chris Fleizach <cfleizach@apple.com>wrote:
On 26. aug. 2010, at 11.49, Darin Adler wrote:
On Aug 26, 2010, at 11:35 AM, Chris Fleizach wrote:
for (...; ...; ...) { }
So maybe this is the best option. I can add a style guide check for that, unless there are objections
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
webkit-check-style should probably be amended as well On Aug 26, 2010, at 12:48 PM, James Robinson wrote:
The style guide currently covers this http://webkit.org/coding/coding-style.html:
4. Control clauses without a body should use empty braces: Right: for ( ; current; current = current->next) { } Wrong: for ( ; current; current = current->next);
- James
On Thu, Aug 26, 2010 at 12:22 PM, Chris Fleizach <cfleizach@apple.com> wrote:
On 26. aug. 2010, at 11.49, Darin Adler wrote:
On Aug 26, 2010, at 11:35 AM, Chris Fleizach wrote:
for (...; ...; ...) { }
So maybe this is the best option. I can add a style guide check for that, unless there are objections
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
On Thu, Aug 26, 2010 at 1:12 PM, Chris Fleizach <cfleizach@apple.com> wrote:
webkit-check-style should probably be amended as well
Please file a bug. Feel free to cc hamaji@chromium.org, levin@chromium.org, cjerdonek@webkit.org
On Aug 26, 2010, at 12:48 PM, James Robinson wrote:
The style guide currently covers this http://webkit.org/coding/coding-style.html:
4. Control clauses without a body should use empty braces: Right:
for ( ; current; current = current->next) { }
Wrong:
for ( ; current; current = current->next);
- James
On Thu, Aug 26, 2010 at 12:22 PM, Chris Fleizach <cfleizach@apple.com>wrote:
On 26. aug. 2010, at 11.49, Darin Adler wrote:
On Aug 26, 2010, at 11:35 AM, Chris Fleizach wrote:
for (...; ...; ...) { }
So maybe this is the best option. I can add a style guide check for that, unless there are objections
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
_______________________________________________ webkit-dev mailing list webkit-dev@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev
participants (5)
-
Chris Fleizach
-
Darin Adler
-
David Levin
-
James Robinson
-
Nico Weber