alwaysAssert() [was: Against enforce()]

dsimcha dsimcha at yahoo.com
Thu Mar 17 13:49:11 PDT 2011


== Quote from Walter Bright (newshound2 at digitalmars.com)'s article
> On 3/17/2011 12:32 PM, dsimcha wrote:
> > I've asked for this before and I'll ask again:  Can we **please** put an
> > alwaysAssert() function (or an abbreviation of this to make it less verbose) in
> > Phobos?  I proposed this once before and it wasn't well liked for some reason
> > This reminded me to persist a little about it.
> Not always the prettiest, but you can write:
>      if (!condition) assert(0);
> The assert(0) will be replaced with a HLT instruction even in release mode.

This is better than nothing, but not enough to convince me to stop abusing
enforce().  I much prefer to have a real alwaysAssert() function that gives a
file, a line number and an error message.


More information about the Digitalmars-d mailing list