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><div><br></div>-- <br>Bye,<br>Gor Gyolchanyan.<br>