On Sat, 3 Mar 2001, Andreas Mohr wrote: [...]
- changed all terminating ";" of isolated for loops to " ;" to indicate the loop's isolation.
IMHO, for such loops the following would be much clearer:
<init_expression>; while (<test_condition>) { <update_expression>; }
(ok, you can also put '{' on the next line)
Please do the same for these for loops in the future.
???
Somebody might want to write a Wine coding guidelines article...
$ wg . -E 'for *(' | grep -E ') *; *$'` | wc -l 96
(wg is my recursive source grep script)
Maybe we should ask people to put the for and the instruction it applies to on separate lines. Combined with the suggestion above this would make it easier to check for this kind of bug.
P.S.: I just *knew* that at least one other for loop in Wine would be wrong, too ;-)
Yep, I should have done that myself (if you find a generic bug, always check for other similar bugs).
-- Francois Gouget fgouget@free.fr http://fgouget.free.fr/ In a world without fences who needs Gates?
On Sat, Mar 03, 2001 at 07:17:41PM -0800, Francois Gouget wrote:
On Sat, 3 Mar 2001, Andreas Mohr wrote: [...]
- changed all terminating ";" of isolated for loops to " ;" to indicate the loop's isolation.
IMHO, for such loops the following would be much clearer:
<init_expression>; while (<test_condition>) { <update_expression>; }
(ok, you can also put '{' on the next line)
Right.
Please do the same for these for loops in the future.
???
Well, I just meant that they should always use " ;" instead of ";". But your proposal is probably much better.
Somebody might want to write a Wine coding guidelines article...
$ wg . -E 'for *(' | grep -E ') *; *$'` | wc -l 96
(wg is my recursive source grep script)
Maybe we should ask people to put the for and the instruction it applies to on separate lines. Combined with the suggestion above this would make it easier to check for this kind of bug.
Correct.
P.S.: I just *knew* that at least one other for loop in Wine would be wrong, too ;-)
Yep, I should have done that myself (if you find a generic bug, always check for other similar bugs).
I always do that when someone spots a generic bug :-)
Andreas Mohr
Andreas Mohr wrote:
On Sat, Mar 03, 2001 at 07:17:41PM -0800, Francois Gouget wrote:
On Sat, 3 Mar 2001, Andreas Mohr wrote: [...]
- changed all terminating ";" of isolated for loops to " ;" to indicate the loop's isolation.
IMHO, for such loops the following would be much clearer:
<init_expression>; while (<test_condition>) { <update_expression>; }
(ok, you can also put '{' on the next line)
Right.
Why, what's wrong with a for loop?
So far we have these choices: for(init,test,update); /* original */ for(init,test,update) ; /* with space */ init; while(test) { update; }
What about simply: for(init,test,update) ;
Putting the semicolon on the next line indented makes sense IMHO. Solves the problem of confusing it with a for loop accidently having a semicolon at the end and these kind that intentionally have one and is visible to a human at a very very quick glance. The only expense is ONE line.
Please do the same for these for loops in the future.
???
Well, I just meant that they should always use " ;" instead of ";". But your proposal is probably much better.
I dunno, I like mine but shit we are gonna start a really bad coding-style war here if we continue with this.
Somebody might want to write a Wine coding guidelines article...
$ wg . -E 'for *(' | grep -E ') *; *$'` | wc -l 96
(wg is my recursive source grep script)
Maybe we should ask people to put the for and the instruction it applies to on separate lines. Combined with the suggestion above this would make it easier to check for this kind of bug.
Correct.
Just don't specify an indentation style, lest we be stuck with 2 or 3 spaces for an indent instead of a nice single 8-space tab (am I the only one here who prefers tabs to spaces?)
As far as specifying using while instead of for, I am not such a big fan of that either. Personally I feel whoever is writing the code should decide. Requiring a space between the ) and ; or requiring the semicolon on the next line indented once more is probably the best way to go. Even an either-or approach on this would be acceptable.
P.S.: I just *knew* that at least one other for loop in Wine would be wrong, too ;-)
Yep, I should have done that myself (if you find a generic bug, always check for other similar bugs).
I always do that when someone spots a generic bug :-)
Surprised there was only one of these that was for real incorrect. I have accidently put that semicolon there on several late-night programming sessions. Usually you catch it pretty quick though since when you run the code it does some really strange shit.
-Dave
On Sun, Mar 04, 2001 at 06:21:22AM -0600, David Elliott wrote:
Why, what's wrong with a for loop?
So far we have these choices: for(init,test,update); /* original */ for(init,test,update) ; /* with space */ init; while(test) { update; }
What about simply: for(init,test,update) ;
Putting the semicolon on the next line indented makes sense IMHO. Solves the problem of confusing it with a for loop accidently having a semicolon at the end and these kind that intentionally have one and is visible to a human at a very very quick glance. The only expense is ONE line.
Yep. I've been thinking of that, too.
Please do the same for these for loops in the future.
???
Well, I just meant that they should always use " ;" instead of ";". But your proposal is probably much better.
I dunno, I like mine but shit we are gonna start a really bad coding-style war here if we continue with this.
*g*
Somebody might want to write a Wine coding guidelines article...
$ wg . -E 'for *(' | grep -E ') *; *$'` | wc -l 96
(wg is my recursive source grep script)
Maybe we should ask people to put the for and the instruction it applies to on separate lines. Combined with the suggestion above this would make it easier to check for this kind of bug.
Correct.
Just don't specify an indentation style, lest we be stuck with 2 or 3 spaces for an indent instead of a nice single 8-space tab (am I the only one here who prefers tabs to spaces?)
Yep, specify anything, but please stay far away from indentation rules. Else the coding style war will strike again... Personally I prefer 4-spaced indentation in order to prevent 80 char limit overflow, but that's probably not such a good choice, as you should create a new function anyway if you get into overflow mode due to tabbed indents.
As far as specifying using while instead of for, I am not such a big fan of that either. Personally I feel whoever is writing the code should decide. Requiring a space between the ) and ; or requiring the semicolon on the next line indented once more is probably the best way to go. Even an either-or approach on this would be acceptable.
ACK.
I just want to make sure that we do NOT have the ); combo usually used for function call termination, so that it's obvious that the coder intended something different with this for loop.
Andreas Mohr
(hope I don't set off a flame war like last time I posted to the list... ;^)
I'd like to suggest that rather than using the " ;" as a null statement, Wine should either use "{}" or { }
My reasons are as follows:
1) I get suspicious if I see a naked semicolon on a line. I wonder if somebody has accidentally pressed return where they didn't mean to. A pair of braces is a lot more deliberate. 2) I usually find myself needing to put something in the loop later. If there's already braces, that simplifies throwing a TRACE or something in the loop, and removing it later.