Alias syntax removal

Timon Gehr timon.gehr at gmx.ch
Sun Feb 24 05:01:38 PST 2013


On 02/10/2013 03:42 PM, kenji hara wrote:
> 2013/2/10 kenji hara <k.hara.pg at gmail.com <mailto:k.hara.pg at gmail.com>>
>
>
>     I opened the pull request #1413 in the beta term for 2.061, but it
>     had _accidentally_ released without deeply discussion.
>     https://github.com/D-Programming-Language/dmd/pull/1413
>
>     I think and believe that we MUST reset things.
>
>
> Why I argue that the syntax `alias this = sym;` is wrong?

Do you have any arguments that do not also apply to

alias sym this;

?

> Because:
>
> 1. A normal alias declaration (creating aliased name for existing
> symbol) and alias this feature
> (making a *subtyped*  struct through implicit access to its field)

Actually that is not what subtyping means.

> are entirely different and has distinct semantics.

Yet they already deliberately share the same piece of syntax. The 
problems cannot be attributed to the alias assignment syntax addition.

> They merely share a keyword 'alias'.
>

No, they share the entire declaration syntax.

alias foo this;
alias foo that;

> 2. Instead, we can have much more consistent,

alias foo that; // ok
alias foo this; // ok
alias that=foo; // ok
alias this=foo; // uh...

> useful,

All are of the same usefulness.

> and scalable syntax.
> At the same time, I proposed a new syntax `alias this : ident;` for
> alias this feature.

Yes, what is the point? Why would a new syntax that's deliberately 
inconsistent with alias syntax require an 'alias' keyword? It is not an 
alias. The other special aggregate members are just specially named symbols.

> https://github.com/D-Programming-Language/d-programming-language.org/pull/200
>
> struct S {
>      int value;
>      alias this : value;   // proposed syntax
> }
>
> Benefits of the proposed syntax are:
> 2a. It is consistent with class inheritance syntax `class C : B {}`.

It's hardly consistent, and you were opposed to entirely different 
constructs having similar syntax above!

> 2b. It is scalable for multiple alias this feature, as like `alias this
> : sym1, sym2, ...;` .

TDPL says:

alias sym1 this;
alias sym2 this;
...


>
> If D community highly require the syntax `alias this = sym`, I'll agree
> to adding it again.
> But for that, we should discuss about its cost and benefit.
> ...

The syntax to access the alias this functionality is quite whacky. 
Applying a partial fix without going all the way just increases confusion.





More information about the Digitalmars-d mailing list