Get rid of bit and bit[] ?
Niko Korhonen
niktheblak at hotmail.com
Wed Feb 22 00:28:43 PST 2006
John Stoneham wrote:
> This is one thing I really like about Ada. The compiler will just not
> let you do ANYTHING with a type that requires any kind of implied cast.
> Boolean is Boolean and nothing else. If you've got a Boolean variable,
> you can't add an integer to it, you can't assigned anything other than
> another Boolean to it, and you can't use anything other than a Boolean
> in it's place.
That's indeed how a type safe language should behave. Fine examples are
statically typed functional languages Haskell and O'Caml, which are
*absolutely* type-safe. That is, they have very clear and strict type
rules with no casts. In Haskell converting a truth value to integer is
done via the obvious approach:
b = true
i = if b then 1 else 0
Also you can just forget about accidentally mixing signed and unsigned
values :) This hasn't really bothered me at all while programming in
Haskell or O'Caml. I would gladly exchange "easy boolean to integer
conversion" you people seem to appreciate so much for type safety.
--
Niko Korhonen
SW Developer
More information about the Digitalmars-d
mailing list