Implicit enum conversions are a stupid PITA

Nick Sabalausky a at a.a
Thu Mar 25 01:11:26 PDT 2010


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:hoeukp$2kgv$1 at digitalmars.com...
> Nick Sabalausky wrote:
>> To put it simply, I agree with this even on mere principle. I'm convinced 
>> that the current D behavior is a blatant violation of strong-typing and 
>> smacks way too much of C's so-called "type system".
>
> You're certainly not the first to feel this way about implicit 
> conversions. Niklaus Wirth did the same, and designed Pascal with no 
> implicit conversions. You had to do an explicit cast each time.
>
> Man, what a royal pain in the ass that makes coding in Pascal. 
> Straightforward coding, like converting a string of digits to an integer, 
> becomes a mess of casts. Even worse, casts are a blunt instrument that 
> *destroys* type checking (that wasn't so much of a problem with Pascal 
> with its stone age abstract types, but it would be killer for D).
>
> Implicit integral conversions are not without problems, but when I found C 
> I threw Pascal under the nearest bus and never wrote a line in it again. 
> The taste was so bad, I refused to even look at Modula II and its failed 
> successors.
>
> D has 12 integral types. Disabling implicit integral conversions would 
> make it unbearable to use.

Oh, I absolutely agree that implicit conversions are good in certain cases. 
I was only referring to implicit conversions between enums and the enum's 
base type (regardless of direction).





More information about the Digitalmars-d mailing list