Feature request: extending comma operator's functionality

Tommi tommitissari at hotmail.com
Thu Oct 4 16:11:01 PDT 2012


On Thursday, 4 October 2012 at 22:36:47 UTC, Tommi wrote:
> But I'm not suggesting any kind of change in syntax. This 
> syntax in D currently works (as long as expr2 is convertible to 
> bool):
>
> if (Type var = expr1, expr2)
> {
>     //...
> }
>
> What I'm suggesting is, I think, quite reasonable: make it so 
> that 'var' is visible to 'expr2'.

Uh... I was actually wrong. What that syntax really does is this:

if (Type var = cast(Type)expr2)
{
     //...
}

Didn't see that coming. But I think it might be a bug, because 
assignment expression has precedence over sequencing expression, 
that is, expressions separated by commas.


More information about the Digitalmars-d mailing list