Why I argue that the syntax `alias this = sym;` is wrong?
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) are
entirely different and has distinct semantics.
They merely share a keyword 'alias'.
2. Instead, we can have much more consistent, useful, and
scalable syntax.
At the same time, I proposed a new syntax `alias this : ident;`
for alias
this feature.
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
{}`.
2b. It is scalable for multiple alias this feature, as like
`alias this
: sym1, sym2, ...;` .
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.
Sorry for my poor writing.
Regards.
Kenji Hara
http://forum.dlang.org/thread/[email protected]
http://d.puremagic.com/issues/show_bug.cgi?id=9569