The empty statement ";" - when is it useful?
Don
nospam at nospam.com
Tue Jul 28 00:09:02 PDT 2009
Stewart Gordon wrote:
> Andrei Alexandrescu wrote:
>> D has ";" as the empty statement. In fact I think it's an empty
>> declaration because it can appear at top level.
> <snip>
>
> That's always been one of my peeves. At least, ever since I discovered
> that preventing such common C typos as
>
> if (...);
> {
> ...
> }
>
> isn't implemented by disallowing ";" as a statement altogether, even
> though at the time there was nothing in the spec to _allow_ it.
>
> http://d.puremagic.com/issues/show_bug.cgi?id=327
>
> Walter once claimed that it's useful for automatically generated code.
> Though I'm still not quite sure how.
Yes. He's recently the claimed the same thing about the comma operator,
but I don't buy that argument. I've never needed to use either of them
myself. (In the case of comma, sure it works as a sequence point when
you have: a,b, return a; but it doesn't work for a,b, return b; which is
50% of the cases. I think it's a fallacious argument). Interestingly
CommaExpression doesn't seem to be defined anywhere in the D spec.
>
> Stewart.
More information about the Digitalmars-d
mailing list