Library Typedefs are fundamentally broken

Dicebot via Digitalmars-d digitalmars-d at puremagic.com
Tue Sep 23 09:05:33 PDT 2014


On Monday, 22 September 2014 at 09:39:29 UTC, Don wrote:
> Having said that, though, the success of 'alias this' does 
> raise some interesting questions about how useful the concept 
> of a typedef is. Certainly it's much less useful than when 
> Typedef was created.
>
> My feeling is that almost every time when you want to create a 
> new type from an existing one, you actually want to restrict 
> the operations which can be performed on it. (Eg if you have  
> typedef money = double; then money*money doesn't make much 
> sense). For most typedefs I think you're better off with 'alias 
> this'.

If you have a look at our transition.d it does exactly that right 
now - mixes in the struct with the same name as typedef had and 
does `alias this` for its value field ;)


More information about the Digitalmars-d mailing list