Improving assert-printing in DMD

Per Nordlöw via Digitalmars-d digitalmars-d at puremagic.com
Fri Oct 2 05:15:11 PDT 2015


On Friday, 2 October 2015 at 11:19:51 UTC, Andrei Alexandrescu 
wrote:
> assert(e1 == e2)
>
> could be lowered into:
>
> {
>   auto a = e1, b = e2;
>   if (a == b) return;
>   onAssertFailed!"=="(a, b, __FILE__, __LINE__, __FUNCTION__, 
> __MODULE__);
> }()

So lowering is kind of like macro expansion for AST-nodes, then?

Is DMD clever enough to avoid trigger postblits for

>   auto a = e1, b = e2;
>   if (a == b) return;

? Or is that part of the question whether this will work?

I guess we only need on symbol name for `onAssertFailed` then 
instead of `assertBinOp` and `assertUnOp`, right?


More information about the Digitalmars-d mailing list