Don: > It's very important. If you allow implicit conversion to bool, all kinds > of garbage will compile. You might as well abandon static typing.
Some half-backed ideas. opBool() can be called implicitly when it's required a truth value test, like in if(x), while(x || y), etc. So this produces a type error: bool b = x; and you need the following to call opBool: bool b = cast(bool)x; An alternative solution that I think covers most possible usages of opBool is to try replace: if (x) with if(x.length != 0) (This is what Python does when __nonzero__ method isn't defined). Bye, bearophile
