DIP19: Remove comma operator from D and provision better syntactic support for tuples

Timon Gehr timon.gehr at gmx.ch
Sun Sep 23 15:54:03 PDT 2012


On 09/24/2012 12:11 AM, bearophile wrote:
> ...
>
> Second: removing comma operator from D has some advantages unrelated to
> tuple syntax. Even disallowing bad looking C-like code that uses commas
> is an improvement by itself (but maybe it's not a big enough
> improvement...).

I would think that it isn't an improvement at all. Disallowing some
construct always will also disallow 'bad looking' code that uses it.

>...
>
> 4) This looks simple, but allows things like using BigInt in switch
> cases, implementing a very simple but quite handy pattern-matching, etc:
>
> auto v = tuple(10, 20);
> final switch (v) {
>      case tuple(5, y): { x in scope... } break; // y is not a global
>      case tuple(x, y): { ... } break; // this covers all cases
> }
>
> ...

cases already introduce their own scopes in D, but switch cannot be
extended well to serve such use cases.

I agree with all the other points.


More information about the Digitalmars-d mailing list