Implicit enum conversions are a stupid PITA

Nick Sabalausky a at a.a
Thu Mar 25 15:26:58 PDT 2010


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:hogmgm$oco$1 at digitalmars.com...
> Ellery Newcomer wrote:
>> I guess what I'm trying to say is it doesn't make sense that I can 
>> implicitly import FooA, an external symbol, but not bar(FooA), an 
>> external symbol defined on an external symbol which cannot be implicitly 
>> converted to a local symbol.
>
> And I believe it makes perfect sense! Everywhere else in the language, 
> when you define a local name it *overrides* names in other scopes, it 
> doesn't overload them.

Well, the result of that is that I'm forced to make my "genEnum" library 
utility generate "enum{name of enum}ToString({name of enum} e)" instead of 
"enumToString({name of enum} e)" or else users won't be able to use it 
without a bunch of odd alias contortions that I'm not sure I can wave away 
by including them in the original mixin. (I would have just called it 
"toString", but at the time, that had been giving me some strange troubles 
so I changed it to "enumToString" instead. In retrospect, it was probably 
giving me trouble because of this very same issue.)

Of course, I can live with this as long as it's fixed in D2 (as seemed to be 
the case from the three-module test code I put in another post). But now 
that you're saying this I'm confused as to why that example I posted 
suddenly worked when I compiled it with D2.





More information about the Digitalmars-d mailing list