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. On Mon, Nov 11, 2013 at 1:52 AM, Rikki Cattermole <alphaglosi...@gmail.com>wrote: > On Monday, 11 November 2013 at 09:01:31 UTC, dennis luehring wrote: > >> One of our targets for AST macros should be the ability to >>> replicate roughly linq from c# / .net. >>> >>> An example syntax for use with AST could be: >>> >>> auto data = [5, 7, 9]; >>> int[] data2; >>> query { >>> from value in data >>> where value >= 6 >>> add to data2 >>> } >>> >>> Could be unwrapped to: >>> >>> auto data = [5, 7, 9]; >>> int[] data2; >>> foreach(value; data) { >>> if (value >= 6) data2 ~= value; >>> } >>> >> >> could you add the example to the DIP wiki page >> > > Adding use case section with Linq example. > Please remove / modify as required as is first time editing wiki. >