DIP 50 - AST macros

Jacob Carlborg doob at me.com
Mon Nov 11 02:21:07 PST 2013


On 2013-11-11 11:10, Timothee Cour wrote:
> I would really like to use AST macros for the following use case:
>
> myAssert( x < y);
> //will print, on failure, a message, along with all values appearing
> inside macro myAssert:
> x<y failed: x=..., y=...
>
> myAssert( fun(x,y)==z1+z2)
> //likewise, but nesting down to all individual variables appearing
> inside the macro:
> x=..., y=..., fun(x,y)=..., z1=..., z2=..., bar(z1+z2)=...
>
> This would advantageously replace the plethora of unittest helpers found
> in other languages, eg: CHECK_EQ, CHECK_LEQ, etc.
> Invaluable for debugging or informative unittests and logs.

Agree. That's the first example in the DIP. Although a very simplified 
version.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list