Create mixins from a list of strings

Casper Færgemand" <shorttail at hotmail.com> Casper Færgemand" <shorttail at hotmail.com>
Sat Jan 11 00:35:42 PST 2014


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.


More information about the Digitalmars-d-learn mailing list