Suggestion: "fix" assert(obj)
Kristian Kilpi
kjkilpi at gmail.com
Thu Jun 14 03:09:33 PDT 2007
On Thu, 14 Jun 2007 12:13:10 +0300, Frits van Bommel
<fvbommel at REMwOVExCAPSs.nl> wrote:
> 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.
Good revision, that's what I meant.
>> 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.
Yes, there is that. But I don't see that causing any trouble, even if
that's (a bit?) inconsistant. It just makes asserts more strict (which is
a good thing(tm)). And, by their nature, invariants must always pass.
More information about the Digitalmars-d
mailing list