string overrideState(string s) { // work your magic here, it's normal D code! }void foo(string s)() { mixin(overrideState(s)); }
Unfortunately this won't work if there is a function 'bar' in different module that calls 'foo':
void bar() { foo!"bar"; } void foo(string s)() { mixin(overrideState(s)); ... mixin("bar()"); // just for illustration }