New operator overloading syntax. Was: Does std.bigint compile
bearophile
bearophileHUGS at lycos.com
Fri Feb 26 14:45:08 PST 2010
Don:
> http://www.dsource.org/projects/phobos/browser/trunk/docsrc/operatoroverloading.dd
It says:
223 logical negation operator. More obscurely absent is a unary operator
224 to convert to a bool result.
...
234 if (e) => if (e.opCast!(bool))
235 if (!e) => if (!e.opCast!(bool))
...
238 $(P etc., whenever a bool result is expected. This only happens, however, for
239 instances of structs. Class references are converted to bool by checking to
240 see if the class reference is null or not.
I have asked for this several times, but I didn't know that was accepted :-)
So if you change a class into a struct or the opposite, you have to be careful of changing all such points where the boolean value is asked for.
What does it happen if this semantics is extended to class instances too? I guess this is an unthinkable change.
Bye,
bearophile
More information about the Digitalmars-d
mailing list