Skip to content

[enh] Issue 3011 - alias should have assignment syntax#1187

Merged
andralex merged 2 commits intodlang:masterfrom
9rnsr:fix3011
Oct 22, 2012
Merged

[enh] Issue 3011 - alias should have assignment syntax#1187
andralex merged 2 commits intodlang:masterfrom
9rnsr:fix3011

Conversation

@9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Oct 16, 2012

http://d.puremagic.com/issues/show_bug.cgi?id=3011

This change never break existing code.

@yebblies
Copy link
Contributor

What about alias this?

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 16, 2012

Yet not care it. Tomorrow I'll update for that.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be:

static assert(is(X5 == int));

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nevermind the template is called Test not type. (thought it was eponymous)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a test for aliasing template itself.

@stasoid
Copy link

stasoid commented Oct 17, 2012

What confuses me a little is using function parseType. Does it work good for other symbols as well?
I checked aliasing function, function template and enum constant, all work fine.
Maybe there exists other type of symbol I can't think of that parseType would fail to parse?

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 17, 2012

@stasoid : For all types which yet not known whether that is really type or not in parsing phase, parseType returns TypeIdentifer(will be user-defined type, or symbol), TypeInstance(will be type, expression, or symbol), or TypeSlice(will be dynamic array type or tuple slicing). Then, in semantic analysis phase, they are resolved to actual entities. (It will be done in Type::resolve).
So, there is no problem.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 17, 2012

Updated for the syntax alias this = identifier;

@donc
Copy link
Collaborator

donc commented Oct 17, 2012

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.

@andralex
Copy link
Member

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!

@WalterBright
Copy link
Member

LGTM, but doc changes have to be done, too.

@9rnsr
Copy link
Contributor Author

9rnsr commented Oct 17, 2012

doc changes have to be done, too.

Website fix:
dlang/dlang.org#177

@azizk
Copy link

azizk commented Oct 17, 2012

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.

@andralex
Copy link
Member

Will pull now both compiler and dox. This is great! I think it would be good to implement alias this = xxx; for several reasons. But we can leave that to a future pull request.

andralex added a commit that referenced this pull request Oct 22, 2012
[enh] Issue 3011 - alias should have assignment syntax
@andralex andralex merged commit 6c01188 into dlang:master Oct 22, 2012
dkorpel pushed a commit to pbackus/dmd that referenced this pull request May 10, 2023
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)
kinke pushed a commit to ldc-developers/ldc that referenced this pull request Jun 7, 2023
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants