1 matches bool, 2 matches long

Rob T alanb at ucora.com
Sat Apr 27 14:41:28 PDT 2013


On Saturday, 27 April 2013 at 19:51:48 UTC, Walter Bright wrote:
> An analogous issue comes up here now and then about 'char' and 
> characters. Are chars an 8 byte integer, or are they 
> characters, or are they octets, or should access only be 
> allowed to multibyte characters as an indivisible code point? 
> (This comes up in regards to indexing char[].)

The real problem I think is caused by trying to fit two 
conceptually different things into the same container and then 
merging the two conceptually different behaviors together. It's 
very confusing and causes unexpected conflicts.

My analogy is having two exactly identical containers labeled 
"water", but use one to store water and the other gasoline, then 
wait until someone yells "fire!".

To solve the char problem, what should be done, is have a real 
'char' type and a real 'byte' type to settle the matter, and use 
explicit casting where required.

To transform bool into something sensible that we can all agree 
with, there should a a 'bool' type and a 'bit' type, and use 
explicit casting where required.

What we have instead is a confounding merging of dissimilar 
containers for  conflicting purposes. This is completely 
avoidable and easily so.

--rt


More information about the Digitalmars-d mailing list