Killing the comma operator

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Tue May 10 10:57:38 PDT 2016


On 5/10/16 9:53 AM, Meta wrote:
>> Do you like comma expressions, and think its presence in the language
>> is more pro than con ?
>
> It should've been killed off a long time ago. It only causes bugs and
> can easily be replaced with a library feature if necessary. I think
> Andrei suggested that it should be changed so that the comma expression
> returns `void` instead of the last expression evaluated.

Andrei pointed out (in an earlier PR) that making the return type void 
isn't correct either. You can still use void in some cases, e.g.:

auto foo(a)
{
    return ++a, ++a;
}

This should still be disallowed.

-Steve


More information about the Digitalmars-d mailing list