Interesting rant about Scala's issues

bearophile bearophileHUGS at lycos.com
Thu Apr 3 19:19:20 PDT 2014


Meta:

> I would agree if D actually had type-safe enums.
>
> enum a
> {
>     val = 1
> }
> 	
> enum b
> {
>     val = 1
> }
>
> assert(a.val - b.val == 0);

C enums are mostly type unsafe. C++11 has enum class that is 
strongly typed. D enums are intermediate (and it has final 
switches). I have asked for fully typesafe enums in D, but in 
several years I think Walter has never answered, nor he has 
explained why D has chosen such intermediate point. I presume 
this choice is based on practical reasons, but I don't know 
exactly what they are (perhaps to minimize the number of casts). 
D used to have several corners of weak typing (like a partial 
confusion between pointers and dynamic arrays) that later have 
being (painfully and slowly) fixed (and this despite D Zen is 
supposed to prefer a strict design first, followed by some 
relaxations later).

Bye,
bearophile


More information about the Digitalmars-d-announce mailing list