Allow alias this to use assignment-style syntax#15122
Allow alias this to use assignment-style syntax#15122dlang-bot merged 2 commits intodlang:masterfrom
alias this to use assignment-style syntax#15122Conversation
|
Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#15122" |
See DMD PR for rationale: dlang/dmd#15122
|
Spec PR: dlang/dlang.org#3589 |
|
CI failure on macOS is issue 23846, currently affecting all DMD PRs. |
|
Added changelog. |
|
Thank you @pbackus for tackling this issue! Reading the old discussions, I get the impression that What do you all think think about the two alternatives:
|
|
@PetarKirov This is an addition, not a replacement. As far as I know there are no plans to get rid of |
Most likely, that's only because #1413 was merged and we dropped the ball on #1341. If the case was reversed, it's likely that that if the old
I don't follow. As I mentioned before, "alias this" is about sub typing, so the |
|
Btw Dart will have a similar feature called inline classes: https://github.com/dart-lang/language/blob/main/accepted/future-releases/inline-classes/feature-specification.md |
Yes. Any redesign or replacement for
This argument applies equally well to both Again, this PR is not a referendum on |
|
Atila approved this in an email |
|
Would like to see a spec PR for this. |
|
@WalterBright Spec PR is dlang/dlang.org#3589, as previously mentioned. |
|
good |
820dced to
5bee22e
Compare
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 existingalias 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 analias thisdeclaration.[1] #1187
[2] https://dlang.org/changelog/2.061.html
[3] #1413
[4] https://dlang.org/changelog/2.062.html
[5] dlang/dlang.org#200 (comment)