OR, better yet:<div><br></div><div>mixin MyMixin</div><div>{</div><div><div style="font-family:arial,sans-serif;font-size:13px">    foreach(i; 0..10)</div><div style="font-family:arial,sans-serif;font-size:13px">        MyMixin ~= "writeln(" ~ to!string(i); ~ ");\n"'</div>
}</div><div><br></div><div>And this could be printed out as a pragma(msg, ...) or into a .log file or anywhere else. This way it's easy to see what did end up being mixed in.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Nov 1, 2012 at 7:55 PM, Gor Gyolchanyan <span dir="ltr"><<a href="mailto:gor.f.gyolchanyan@gmail.com" target="_blank">gor.f.gyolchanyan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I find myself doing this very very often and it pains me to write ugly code like this over and over again:<br clear="all"><div><br></div><div>mixin(()=>{</div><div><br></div><div>    string result;</div><div>    foreach(i; 0..10)</div>

<div>        result ~= "writeln(" ~ to!string(i); ~ ");\n"'</div><div>    return result;</div><div><br></div><div>}());</div><div><br></div><div>All it does is generates a string in a delegate, which is immediately called and passed to a mixin.</div>

<div>Almost all mixins contain generated strings and most if them need a dedicated string generator.</div><div>I don't want to propose new syntax, because we all know that new syntax is the last thing that will be developed, considering the number of bugs out there. The first thing I wanted to do was this:</div>

<div><br></div><div>mixin</div><div>{</div><div><div>    foreach(i; 0..10)</div><div>        mixin ~= "writeln(" ~ to!string(i); ~ ");\n"'</div>}</div><div><br></div><div>I'm not suggesting this to be implemented, this is just what I automatically wanted to write.</div>

<div>Anybody else had this kind of thoughts?</div><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>
</div>