What happened to the alias this = identifier syntax in 2.062?

Jonathan M Davis jmdavisProg at gmx.com
Sat Feb 23 01:23:02 PST 2013


On Saturday, February 23, 2013 09:47:54 Chris Nicholson-Sauls wrote:
> On Friday, 22 February 2013 at 21:23:04 UTC, Timon Gehr wrote:
> > I guess the main issue is that alias blah this; shouldn't have
> > made it into the grammar in the first place. But this was
> > obviously done in order to establish a broken analogy to the
> > other uses of alias. Either alias this=blah; must be kept or
> > the alias this syntax should be deprecated in favour of a
> > specially named member function.
> 
> I believe the alias syntax was based on typedef, which was
> inherited from C, and has now been removed from D; so the
> justification was there in the past, but now absent which is why
> the change is happening now.

alias bar = foo;

was added simply because a number of folks didn't like

alias foo bar;

Both will continue to be supported. The only issue here is the fact that when

alias bar = foo;

was added,

alias this = blah;

was also added, but it was suddenly removed with the most recent release. 
Whether it's a good idea to disallow it or not, I don't know, but it broke 
people's code when it was removed, because some folks had started to use it - 
hence the complaints.

alias bar = foo;

is unaffected however.

> As far as replacing 'alias...this' with a member function, that's
> precisely how it *used* to be done with opDot(), but it suffered
> from overhead. I had thought, at the time 'alias...this' was
> first introduced, that the two were meant to live side by side,
> but then the realization came that one could actually achieve
> opDot's purpose with clever use of 'alias...this' so the latter
> fell out of favor.  Alas.

alias this is supposed to completely replace opDot, and it's far more flexible 
than opDot, so there's really no reason to have opDot anymore. For whatever 
reason, opDot doesn't appear to have been actually deprecated yet, but it's 
supposed to be getting the axe at some point.

- Jonathan M Davis


More information about the Digitalmars-d mailing list