On 01/11/2014 09:35 AM, "Casper Færgemand" <shortt...@hotmail.com>" wrote:
On Saturday, 11 January 2014 at 07:50:51 UTC, Jakob Ovrum wrote:
Your problem is probably better solved without string mixins, but we'd
probably need to see some code or more elaboration to accurately
suggest a solution.
enum semanticArray = ["test"];
mixin(`T ` ~ semanticArray[0] ~ `(T)(T t) {
t.name ~= "` ~ semanticArray[0] ~ `";
return t;
}`);
This will mixin a single templated function named "test", which changes
an AST node's name to whatever it was concatenated with "test". I want
this to happen automatically for any length of semanticArray.
import std.string, std.algorithm;
enum semanticArray = ["derp", "lala"];
mixin(semanticArray.map!(a=>`T `~a~`(T)(T t) {
t.name ~= "`~a~`";
return t;
}`).join());