Walter Bright:

Because every cast breaks the type system. A type system that requires too many casts for normal things is NOT a type safe system.

I have explained this on numerous occasions.

You have discussed many times about the unsafety of casts and I agree with your point of view. I try to reduce the number of casts as much as possible in my code (and recently I have replaced many "cast(double)x" with nice "double(x)", as time passes D allows to remove more and more casts from the code, this is an improvement).

You see I care of casts also from the little casts statistic I've done on your Warp:$2r80$
Or from answers I keep giving in D.learn, where I suggest to minimize the usage of casts:

But since I follow D development and I write D code I don't remember any kind of discussion regarding the specific disadvantages of a stronger typed enum. This means answering questions like: what does it happen if D enums become strongly typed? How many casts is this going to cause in D code? Is it true that such enum casts are going to be worse than type unsafety of the current design? I don't remember seeing any little study that shows that stronger casts in D increase a lot the number of casts. Perhaps this little study was done before I have started to use D1 and I have missed it.

I suspect that in my D code most cast usage does not need casts if you replace them with stronger casts as the "enum class" of C++11, but I have no proof of this.


Reply via email to