Assert
David B. Held
dheld at codelogicconsulting.com
Sat Jun 30 09:34:57 PDT 2007
Lutger wrote:
> [...]
> Not impossible, but ugly:
>
> char[] enforce(char[] cond, char[] msg)
> {
> return "if (!(" ~ cond ~ "))
> throw new Exception(\"" ~ cond ~ ": " ~ msg ~ "\");";
> }
>
> mixin(enforce("ptr != null", "foo() failed"));
Well, "stringizing by hand" isn't exactly in the repertoire of
possibility that I was considering, given that we can write any code we
want in a mixin statement. Clearly, this kind of solution is less than
ideal.
Dave
More information about the Digitalmars-d
mailing list