Re: What's a good approach to DRY with the block code of a case-statement?

2021-04-28 Thread z via Digitalmars-d-learn
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

Re: What's a good approach to DRY with the block code of a case-statement?

2021-04-26 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 26 April 2021 at 20:39:55 UTC, Jack wrote: I have a block of code that the only thing that change is the type passed in one of the template functions called so I'd like to make a DRY for this. But I'm not just replacing by a function due to control-flow, for example, there are

What's a good approach to DRY with the block code of a case-statement?

2021-04-26 Thread Jack via Digitalmars-d-learn
I have a block of code that the only thing that change is the type passed in one of the template functions called so I'd like to make a DRY for this. But I'm not just replacing by a function due to control-flow, for example, there are if-statements where one just break and the other return 0.