[enh] Issue 3011 - alias should have assignment syntax#1187
[enh] Issue 3011 - alias should have assignment syntax#1187andralex merged 2 commits intodlang:masterfrom
Conversation
|
What about alias this? |
|
Yet not care it. Tomorrow I'll update for that. |
There was a problem hiding this comment.
Shouldn't this be:
static assert(is(X5 == int));There was a problem hiding this comment.
Oh nevermind the template is called Test not type. (thought it was eponymous)
There was a problem hiding this comment.
It is a test for aliasing template itself.
|
What confuses me a little is using function parseType. Does it work good for other symbols as well? |
|
@stasoid : For all types which yet not known whether that is really type or not in parsing phase, |
|
Updated for the syntax |
|
The code looks good to me. But this changes the language syntax, needs approval from Walter. I think it's a HUGE improvement over the existing syntax. |
|
Walter and I have discussed this many times, and we're both in favor of it. I hereby submit my formal approval. @WalterBright please advise. Thanks! |
|
LGTM, but doc changes have to be done, too. |
Website fix: |
|
I think alias this = X; shouldn't be treated specially, because there's no good reason for it. Since we're changing the syntax anyway, which surely doesn't happy very often, why not do it properly and with foresight? If I remember right, it was mentioned that multiple aliases to 'this' will be supported some time. In that case it wouldn't be smart to restrict the new syntax like that. |
|
Will pull now both compiler and dox. This is great! I think it would be good to implement |
[enh] Issue 3011 - alias should have assignment syntax
When assignment-style syntax for alias declarations was first implemented in DMD 2.061 [1][2], `alias this = identifier;` was accepted as equivalent to the existing `alias identifier this;`. One release later, in DMD 2.062, it was removed. [3] The rationale for this change, given in both the changelog [4] and a related spec PR thread [5], was to allow for the possibility that, in the future, the syntax `alias this = super.this;` might be used to merge a derived class's constructor overload set with that of its base class. However, this proposal was never implemented, and seems to have been abandoned in the intervening years. For the sake of consistency, and since the rationale for its removal no longer applies, this commit reinstates `alias this = identifier;` as valid syntax for an `alias this` declaration. [1] dlang#1187 [2] https://dlang.org/changelog/2.061.html [3] dlang#1413 [4] https://dlang.org/changelog/2.062.html [5] dlang/dlang.org#200 (comment)
When assignment-style syntax for alias declarations was first implemented in DMD 2.061 [1][2], `alias this = identifier;` was accepted as equivalent to the existing `alias identifier this;`. One release later, in DMD 2.062, it was removed. [3] The rationale for this change, given in both the changelog [4] and a related spec PR thread [5], was to allow for the possibility that, in the future, the syntax `alias this = super.this;` might be used to merge a derived class's constructor overload set with that of its base class. However, this proposal was never implemented, and seems to have been abandoned in the intervening years. For the sake of consistency, and since the rationale for its removal no longer applies, this commit reinstates `alias this = identifier;` as valid syntax for an `alias this` declaration. [1] dlang/dmd#1187 [2] https://dlang.org/changelog/2.061.html [3] dlang/dmd#1413 [4] https://dlang.org/changelog/2.062.html [5] dlang/dlang.org#200 (comment)
http://d.puremagic.com/issues/show_bug.cgi?id=3011
This change never break existing code.