-
-
Notifications
You must be signed in to change notification settings - Fork 380
Change new alias syntax to alias this : identifier
#200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
If this is acceptable, we should merge fixes before 2.061 release. |
I think this change makes a lot of sense. @WalterBright @andralex opinions? |
But |
@AndrejMitrovic Yes, this change is just for |
That does mean that people will have to get used to two syntaxes. The change in this pull is logical though (especially with multiple alias this), so I support it. |
@AndrejMitrovic: Three syntaxes ( |
Might you misunderstand? The proposal in here is: we should have two syntaxes ( |
@9rnsr: Ah, okay, I didn't look at the diff and got it wrong. In this case, I'm rather indifferent towards this change: It is a new syntax to remember, but then AliasThis is sufficiently different in behavior to a normal AliasDeclaration so that conflating them syntax-wise is questionable anyway. |
I thinking having 'alias a = b' be different when 'a' is 'this' is a horrible idea. Either both change to use ':' or neither do. Also, a syntax change really ought to go through the newsgroup, not stealth through a pull. |
Thinking about it some more, the feature doesn't really pull its own weight, so I've changed my mind.
Agreed.
Maybe, but it wouldn't make much sense in structs. And we don't want people to assume that using Also, a similar argument like your own point 1):
Using multiple alias this should be very rare, and you can still use two alias declarations instead via |
If we want to allow aliasing of superclass constructors, the current So making See discussion (from 2009): |
I opened a pull dlang/dmd#1413 to remove the syntax from the 2.061 release. We should leave room for debate about the syntax. |
What's the status of this? |
Debate still pending. |
A quick summary to aid the discussion:
... with the justification that "this aliasing" and "normal aliasing" are different concepts An alternative More debate is ensuing on the DMD pull request, dlang/dmd#1341, and should probably continue there instead of here. |
Closing, seeing that the DMD pull request has been closed in January. |
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)
A new alias this syntax is introduced by #177, but after that, I thought that was not good.
Then, I'd like to replace it to the syntax
alias this : identifier;
.Reasons:
alias this
is a completely different concept with normalalias
declaration.class D : C, I1, I2 {}
.alias this : ident1, ident2;
.How about?
Blocked by dlang/dmd#1341