```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.
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:
- What's a good approach to DRY with the bl... Jack via Digitalmars-d-learn
- Re: What's a good approach to DRY wi... ag0aep6g via Digitalmars-d-learn
- Re: What's a good approach to DRY wi... z via Digitalmars-d-learn