assert(obj) is an atrocity

Alex Rønne Petersen xtzgzorex at gmail.com
Sun Nov 13 11:28:18 PST 2011


On 13-11-2011 19:43, Andrej Mitrovic wrote:
> On 11/13/11, Alex Rønne Petersen<xtzgzorex at gmail.com>  wrote:
>> I'd just like to add, regarding asserting invariants: Why not just *make
>> invariants callable*? I.e. obj.invariant() invokes the invariant
>> function.
>
> I think you would have to wrap it as debug() { obj.invariant(); },
> otherwise you would end up calling the invariant in release-mode.

The compiler could easily do that work, however.

- Alex


More information about the Digitalmars-d mailing list