Reduce redundancy in alias

Frank Benoit keinfarbton at googlemail.com
Thu Jun 5 18:07:22 PDT 2008


Paul D. Anderson schrieb:
> One problem is that you could intend to create an alias such as 
> 
> B.foo bar
> 
> but mistakenly omit the alias name:
> 
> B.foo
> 
> and there would be no indication that an error was made until you tried to use 'bar' somewhere in the code. The error message would tell you it wasn't defined, but not where the mistake was made.
> 
> An alternative would be to use a different keyword for this case, such as "brief" or "abbrev" or "unqual". (Or "sobriquet".) Then if an alias was intended but omitted it would still get flagged, and if an unqualified usage was intended but an alias was mistakenly added it would also get flagged.
> 
> Paul
> 
> 
> Paul

This argument can be seen also in the opposite direction. In the above 
example to alias the super method, if you do a typo, this will also give 
no compile error and make very bad runtime errors. So you can see that 
as even worse.
class D : B {
   alias B.foo fooo;
   void foo( long a ){}
}



More information about the Digitalmars-d mailing list