Skip to content

Conversation

9rnsr
Copy link
Contributor

@9rnsr 9rnsr commented Dec 1, 2012

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:

  1. alias this is a completely different concept with normal alias declaration.
  2. That is more consistent with the base class list class D : C, I1, I2 {}.
  3. That is fairly easy to enhanced for the multiple alias this in the future, like alias this : ident1, ident2;.

How about?

Blocked by dlang/dmd#1341

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 1, 2012

If this is acceptable, we should merge fixes before 2.061 release.

@alexrp
Copy link
Contributor

alexrp commented Dec 1, 2012

I think this change makes a lot of sense. @WalterBright @andralex opinions?

@ghost
Copy link

ghost commented Dec 1, 2012

But alias newSym = oldSym stays the same?

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 1, 2012

@AndrejMitrovic Yes, this change is just for alias this syntax only.

@ghost
Copy link

ghost commented Dec 1, 2012

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.

@dnadlinger
Copy link
Contributor

@AndrejMitrovic: Three syntaxes (alias xyz this, alias this = xyz, alias this : xyz).

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 1, 2012

Three syntaxes (alias xyz this, alias this = xyz, alias this : xyz).

Might you misunderstand? The proposal in here is: we should have two syntaxes (alias xyz this and alias this : xyz) instead of (alias xyz this and alias this = xyz).

@dnadlinger
Copy link
Contributor

@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.

@braddr
Copy link
Member

braddr commented Dec 1, 2012

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.

@ghost
Copy link

ghost commented Dec 1, 2012

so I support it

Thinking about it some more, the feature doesn't really pull its own weight, so I've changed my mind.

1 alias this is a completely different concept with normal alias declaration.

Agreed.

2 That is more consistent with the base class list class D : C, I1, I2 {}.

Maybe, but it wouldn't make much sense in structs. And we don't want people to assume that using alias this : A, B in a struct means the struct can also inherit via struct S : A, B. So there can be potential confusion here.

Also, a similar argument like your own point 1): alias this is a different feature from inheritance, so using the same syntax might not be a good idea.

3 That is fairly easy to enhanced for the multiple alias this in the future, like alias this : ident1, ident2;.

Using multiple alias this should be very rare, and you can still use two alias declarations instead via alias this = A; alias this = B;, so the new syntax doesn't fix a blocking issue.

@ntrel
Copy link
Contributor

ntrel commented Dec 27, 2012

  1. alias this is a completely different concept with normal alias declaration.

If we want to allow aliasing of superclass constructors, the current alias this syntax appears to be in conflict with normal aliases:
alias this = super.this;

So making alias this have different syntax might be helpful (if it's not too late to change).

See discussion (from 2009):
http://forum.dlang.org/post/op.u36pc3y4o7cclz@korden-pc

@9rnsr
Copy link
Contributor Author

9rnsr commented Dec 27, 2012

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.

@andralex
Copy link
Member

What's the status of this?

@tgehr
Copy link
Contributor

tgehr commented Jun 12, 2014

Debate still pending.

@JinShil
Copy link
Contributor

JinShil commented Jun 13, 2014

A quick summary to aid the discussion:

  1. [enh] Issue 3011 - alias should have assignment syntax dmd#1187 introduces a new assignment syntax: alias newname = existingname and alias this = existingname syntax.
  2. After the fact, it is discovered that the alias this = existingname conflicts with the ability to alias base (i.e. super class) constructors: alias this = super.this
  3. Kill the syntax alias this = sym; dmd#1413 reverts the "=" syntax for alias this only.
  4. This pull request and the corresponding DMD pull request, Change new alias syntax to alias this : identifier dmd#1341, suggests a colon syntax, alias this : existingname, as a workaround resulting 4 aliasing syntaxes...
// normal aliasing
alias existingname newname;
alias newname = existingname;

// this aliasing
alias existingname this;
alias this : existingname;

... with the justification that "this aliasing" and "normal aliasing" are different concepts

An alternative opThis proposal was posted by @tgehr on the forum (http://forum.dlang.org/post/ld5c9r$18lt$1@digitalmars.com)

More debate is ensuing on the DMD pull request, dlang/dmd#1341, and should probably continue there instead of here.

@CyberShadow
Copy link
Member

Closing, seeing that the DMD pull request has been closed in January.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants