bearophile wrote: > - assert(0); to mean HALT, that gives some problems I like it. It's convenient and clear - assert(0) means you cannot proceed in any situation, and that should include release modes. (Indeed, IMO any assert that can be proven to fail at compile time should always remain and one proven to succeed can always be removed.
Only if the compiler isn't sure does it actually do a runtime check. -release simply says "if not sure, trust me and don't bother" instead of the default of "if not sure, check for me". I think the compiler pretty much does this already.) > - assert(class_instance); that calls its invariant. (I vaguely > remember a problem with this with struct instance invariants). Again, I think this makes sense too. assert(n) is saying, in principle, "ensure n is valid". Calling the invariant is part of ensuring it is valid. The only problem is a minor bug - it forgets to check for null before calling the invariant. That should, of course, be fixed, but the main behavior makes sense.