halt with optional message?

bearophile bearophileHUGS at lycos.com
Thu Aug 11 04:00:03 PDT 2011


Is it possible, and is it a good/wise idea to modify D a bit so that in release mode this:

assert(0);

becomes a HLT, while in release mode this 

assert(0, "message");

Becomes the same thing as:

core.stdc.stdlib.puts("message");
HTL

?

What I asking here is support for optional messages in assert(0) too, and if it's a good idea.

Note: writing puts before an assert(0) in D code is not the same thing, because you are not supposed to be able to use puts in a pure function:

void foo() pure {
    puts("message");
    assert(0);
}

Bye,
bearophile


More information about the Digitalmars-d mailing list