Inline mixin

Inquie via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 14 10:38:33 PDT 2017


Many times I need to build a type using a string. I have to 
resort to building the entire expression/statement using the 
mixin:

mixin("This is a long and complex expression where I only need to 
modify X")

Is there any way to do a sort of "inline mixin"?


This is a long and complex expression where I only need to modify 
mixin("X")

?

e.g.,

mixin("int "~name~" = 3;")

vs

int mixin(name) = 3;

(a gross simplification)



Maybe a template could handle it or is something like this 
impossible by D's gramar?



More information about the Digitalmars-d-learn mailing list