Suggestion: "fix" assert(obj)

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Jun 14 02:13:10 PDT 2007


Kristian Kilpi wrote:
> That is, if an object is used inside an assert (anywhere inside it), 

I'd change that to "if an object is used *as a boolean value* inside an 
assert". That way the behavior won't change when comparing objects to 
each other and calling member functions on them.

> then first it's checked that the object is not null, and then its 
> invariants are run:

Other than that, the only problem I'd have with this is that object 
references in asserts still have different semantics than object 
references in normal boolean expressions (like if/while/whatever 
conditions). That's still better than what we have currently, though.



More information about the Digitalmars-d mailing list