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





------- Comment #3 from and...@metalanguage.com  2009-01-28 19:39 -------
(In reply to comment #2)
> (In reply to comment #1)
> > Oh, and aliasing this should also nicely take care of the "inner name 
> > trick":
> > 
> > template Blah!(T) { alias T Blah; }
> > 
> > becomes
> > 
> > template Blah!(T) { alias T this; }
> > 
> > Much cleaner because it clarifies the intent and allows "one point of
> > renaming".
> > 
> 
> struct S
> {
>     mixin Blah!(int); // what happens?
> }
> 
> If 'this' always refers to the template, you can't do cute things like mixing
> in support for operations on values of type S.
> 
> If 'this' refers to the template sometimes and to the enclosing scope in
> others, it's confusing.

I think that clips the toenails of my impetus.

> Then again, I can't tell you how often I've mistyped the name of a template in
> one of the nine places inside it, only to not find out until just the right
> conditions are met and then the compiler dies with a "voids have no value"
> error deep in some template instantiation which I can't figure out because it
> doesn't print a damned traceback.  Sigh.  
> 
> Another problem with the "alias X this;" in templates is that it only works 
> for
> aliases.  You can't do "enum this = 5;".
> 

But you can do 

enum _zis = 5;
alias this _zis;


Andrei


-- 

Reply via email to