1 matches bool, 2 matches long

Jonathan M Davis jmdavisProg at gmx.com
Thu Apr 25 19:28:53 PDT 2013


On Thursday, April 25, 2013 17:35:34 Walter Bright wrote:
> > Is bool more specialized than long
> 
> Yes, because a bool can be implicitly converted to a long, but a long cannot
> be implicitly converted to a bool.

However, given that bool isn't even an integral type, it seems very wrong that 
it would be a better match than something which _is_ an integral type. Given 
that the compiler already inserts explicit casts to bool in conditions to 
solve the primary case where you want a non-boolean value to implicitly 
convert to bool, it really seems to me that the other conversions to and from 
bool which are currently accepted are far too lax. Another example of this 
would be something like "foo" ~ true. I don't understand why conversions like
that are allowed by the spec. They're just going to cause bugs.

- Jonathan M Davis


More information about the Digitalmars-d mailing list