<div dir="ltr">I would really like to use AST macros for the following use case:<div><br></div><div>myAssert( x < y);</div><div>//will print, on failure, a message, along with all values appearing inside macro myAssert:</div>
<div>x<y failed: x=..., y=...</div><div><br></div><div>myAssert( fun(x,y)==z1+z2)<br></div><div>//likewise, but nesting down to all individual variables appearing inside the macro:</div><div>x=..., y=..., fun(x,y)=..., z1=..., z2=..., bar(z1+z2)=...<br>
</div><div><br></div><div>This would advantageously replace the plethora of unittest helpers found in other languages, eg: CHECK_EQ, CHECK_LEQ, etc. </div><div>Invaluable for debugging or informative unittests and logs.</div>
<div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Nov 11, 2013 at 1:52 AM, Rikki Cattermole <span dir="ltr"><<a href="mailto:alphaglosined@gmail.com" target="_blank">alphaglosined@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Monday, 11 November 2013 at 09:01:31 UTC, dennis luehring wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
One of our targets for AST macros should be the ability to<br>
replicate roughly linq from c# / .net.<br>
<br>
An example syntax for use with AST could be:<br>
<br>
auto data = [5, 7, 9];<br>
int[] data2;<br>
query {<br>
from value in data<br>
where value >= 6<br>
add to data2<br>
}<br>
<br>
Could be unwrapped to:<br>
<br>
auto data = [5, 7, 9];<br>
int[] data2;<br>
foreach(value; data) {<br>
if (value >= 6) data2 ~= value;<br>
}<br>
</blockquote>
<br>
could you add the example to the DIP wiki page<br>
</blockquote>
<br></div></div>
Adding use case section with Linq example.<br>
Please remove / modify as required as is first time editing wiki.<br>
</blockquote></div><br></div>