Discussion Thread: DIP 1040--Copying, Moving, and Forwarding--Community Review Round 1

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Mar 15 17:18:19 UTC 2021


On Mon, Mar 15, 2021 at 04:51:19PM +0000, 12345swordy via Digitalmars-d wrote:
> On Monday, 15 March 2021 at 08:01:02 UTC, Walter Bright wrote:
[...]
> > 1. I recommend NEVER using alias this in a class.
> > 
> > 2. I'd like to make it illegal.
[...]
> Then save yourself from future headaches by making it straight up
> illegal for classes to have alias this a struct that have move
> schematics.
[...]

I'm sure Walter would have made alias this illegal in classes a long
time ago, if it were possible without problems.  I'm suspecting the
"don't break existing code" bugbear is among the reasons.

I used to be a big fan of alias this, esp. multiple alias this.  Now,
after some experience with maintaining code that use alias this
willy-nilly, I'm starting to agree with Walter's stance that alias this
in general was a bad idea.  Although there are definitely cases for
which it's actually useful, the problems it brings along make it of
questionable value as a general language feature.  I'd also be in favor
of getting rid of it, at least from classes, if not completely. (The
latter is probably impossible; quite a lot of my own code relies on it,
and I imagine I'm not the only one using it among the users of D.)


T

-- 
People say I'm indecisive, but I'm not sure about that. -- YHL, CONLANG


More information about the Digitalmars-d mailing list