I'd recommend you to use templates with alias parameters but you mentioned that you need to retain function context(for gotos, continue, break, etc...) One thing you could do is mix the ugly mixin solution with the good one:
```D
//inside the function, so that you can access locals
pragma(inline, true)
string getDRYstr(T, parameters...)() {
    static assert(__ctfe);
    string mixedinstr;
    mixedinstr ~= /*code*/;
    static if(/**/){mixedinstr ~= /*code*/;}
    //...
    mixedinstr ~= "break;";
    return mixedinstr
}
```
There is no doubt that it is an ugly solution but the time saved not copy-pasting code could be worth it.

Reply via email to