Killing the comma operator
deadalnix via Digitalmars-d
digitalmars-d at puremagic.com
Tue May 10 14:47:43 PDT 2016
On Tuesday, 10 May 2016 at 17:57:38 UTC, 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
It doesn't make it incorrect, just insufficient.
More information about the Digitalmars-d
mailing list