On Thu, 08 Nov 2012 23:04:17 -0000, bearophile <[email protected]>
wrote:
If this situation is a problem, then here are two of the possible
solutions:
- Do not allow opCast(bool) in classes. How much often do you need
cast(bool) on class instances?
I don't like it, it restricts people from defining a class which
represents a boolean value/state (and casting it to bool).
- Keep cast(bool) in classes, and remove the asymmetry between structs
and classes, if possible. So "if(fclass)" on a class instance calls
opCast(bool). Then to test the value of the reference you use "if(fclass
is null)".
This is a breaking change.
A slightly less breaking change would be to make "if (fclass)" into both a
reference !is null check and a call to any opCast(bool) if it exists.
This would then only break existing code using "if (fclass)" on references
to classes which define opCast(bool) (which return false).
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/