Changing the behavior of the comma operator
Asman01
jckj33 at gmail.com
Tue Mar 25 10:45:20 PDT 2014
On Tuesday, 25 March 2014 at 17:33:20 UTC, Andrei Alexandrescu
wrote:
> After the recent discussions regarding the comma operator, and
> after inspecting the patterns of code affected by it, Walter
> and I would back up the following change to the D language:
>
> 1. The comma operator stays with its current syntax.
>
> 2. The semantics is the same unless warnings are enabled with
> "-w"
>
> 3. In "-w" mode, semantics are changed in that the type of the
> comma operator is NOT the type of its last expression, but
> instead it's void.
>
> 4. Later on the warning will be promoted to a deprecation
> followed by removal from the language.
>
> 5. Reintroducing the result type as a tuple remains a future
> possibility.
>
> We believe the change would be beneficial for the following
> reasons:
>
> 1. Based on druntime and phobos, the breakage is likely to be
> infrequent.
>
> 2. The change may catch (and has caught) important bugs caused
> by misplacing closing parentheses.
>
> 3. Most code using the result of the comma expression looks
> foreign even to seasoned programmers and might gain in clarity
> from a refactor.
>
>
> Please reply to discuss this possibility.
>
>
> Andrei
At first I throught didn't remove comma operator from language
because it will make(possibly) hard to C/C++ guys porting code to
D but instead of it will be allowed but return void type? why is
this better than remove?
but I'm happy this int a = 123,456; will give a type error
instead of compile.
More information about the Digitalmars-d
mailing list