Killing the comma operator
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 10 14:21:42 PDT 2016
On 10.05.2016 19:57, Steven Schveighoffer wrote:
> 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
I suggest we make it a statement instead of an expression and add
special syntax for for-loops.
More information about the Digitalmars-d
mailing list