Less commas
bearophile
bearophileHUGS at lycos.com
Fri Dec 31 05:45:11 PST 2010
Peter Alexander:
> I don't believe it is the job of the compiler to enforce personal style
> preferences.
D2 compiler enforces several good style preferences. Those two style preferences are not just mine, they are enforced by a known C lint tool too. So are the two things I've shown bad/important enough to justify avoiding them?
> If people /really/ want to write obfuscated code then that's up to them
> -- you can't stop them.
This is a very wrong idea. It's the job of the language designers to avoid some syntax traps. So the designers need to find a good middle point between chaos and rigidity.
> If organisations want to enforce style guides
> then that's up to them to manually enforce the style or produce tools to
> do it automatically.
Most programmers don't use those tools or style guides, so those tools don't avoid you to find bad code in the modules you find in some public online repository. Style guides are not enough to avoid many troubles.
> Whatever criteria you select for distinguishing acceptable comma use
> from unacceptable comma use will be subjective,
Is this true in the two cases I've shown?
This is a little C program that compiles with no errors and not even warnings (with -Wall) with GCC 4.5.1:
int main() {
int x;
x = 10, 20;
return 0;
}
The same program compiled with DMD 2.051 produces this error:
test.d(3): Error: long has no effect in expression (20)
> and inevitably some people will be angered by the decision.
That's what discussions and votes are for :-) (Despite some votes have more weight).
Thank you for your comments,
bye,
bearophile
More information about the Digitalmars-d
mailing list