The empty statement ";" - when is it useful?

Don nospam at nospam.com
Tue Jul 28 12:48:58 PDT 2009


Bill Baxter wrote:
> On Tue, Jul 28, 2009 at 12:09 AM, Don<nospam at nospam.com> wrote:
>>> 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.
> 
> You meant to say it doesn't work for a,b, return a;  right?
Yes.
> And I don't think that would be 50% of the cases.  a,b,return b seems
> much more common.

The only time I've considered using comma is with:   assert(a); b = 
foo(a); assert(c); return b;
But you're probably right, it's less than 50% of the time in practice.

> But either way the argument is ridiculous.  It doesn't need to be as
> basic an operator as a single comma just for the sake of making code
> generation easier.
> 
> --bb



More information about the Digitalmars-d mailing list