implicit conversion to alias this

BLM768 blm768 at gmail.com
Thu Jun 28 20:46:41 PDT 2012


>
> I'm fine that the assignment to C is verboten. I'd disallow 
> the 
> first assignments to and would like to know, why they are kept.

OK, now I get it. I'm not sure why they're allowed, either; I 
guess that it's just because it's written with assignment syntax. 
On second thought, it might be for cases where you have a struct 
that, for example, wraps an int to trap overflows. You'd want a 
transparent interface for that; the fact that the initializer for 
C isn't accepted looks like a potential wrinkle in D's design. 
The only reason I can see to restrict the areas in which the 
conversion takes place is to prevent issues with function 
overloading, so the compiler probably should allow your code. 
This might be a good situation for an enhancement request.


More information about the Digitalmars-d-learn mailing list