Implicit enum conversions are a stupid PITA

Walter Bright newshound1 at digitalmars.com
Wed Mar 24 23:08:28 PDT 2010


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.



More information about the Digitalmars-d mailing list