struct Test { int i; alias this = i; // <-- Compilation error } void main() {} The compiler says: deneme.d(121089): Error: no identifier for declarator this deneme.d(121089): Error: alias cannot have initializer
This is working as designed, and probably should be closed. See also: http://forum.dlang.org/thread/evldispcxhyarckmkycg@forum.dlang.org https://github.com/D-Programming-Language/dmd/issues/1413
This is a spec issue covered with http://d.puremagic.com/issues/show_bug.cgi?id=9569
(In reply to comment #2) > This is a spec issue covered with > http://d.puremagic.com/issues/show_bug.cgi?id=9569 https://github.com/D-Programming-Language/d-programming-language.org/pull/284
We have a one alias beast, so now will have two beast... after month three beast ... (period) ... nth beast. Bad idea. Alias this used like class inheritance is bad idea too, because it's not a class inheritance. One syntax, one alias beast - it's good. About multiple alias this: alias this = ...; alias this = ...; ... alias this = ...; It's good because many uses of alias this is not desirable (although allowed) and people will think twice to use this feature. And I think it's more demonstrable when I want to show what I was mean when put it (alias this) into source code.
(In reply to comment #4) > One syntax, one alias beast - it's good. `alias this = ...;` is reserved for aliasing of superclass constructors. See e.g. discussion of https://github.com/D-Programming-Language/dmd/pull/1341 Also documentation is correct now and the error is improved: --- Error: Cannot use syntax 'alias this = i', use 'alias i this' instead ---