Re: Code repetition

2018-05-27 Thread IntegratedDimensions via Digitalmars-d-learn
On Sunday, 27 May 2018 at 13:20:08 UTC, Adam D. Ruppe wrote: On Sunday, 27 May 2018 at 06:47:38 UTC, IntegratedDimensions wrote: Putting the code in a template/function/lambda does not work because of the scopes which will be called when the main function exists. I think you might just be

Re: Code repetition

2018-05-27 Thread Adam D. Ruppe via Digitalmars-d-learn
On Sunday, 27 May 2018 at 06:47:38 UTC, IntegratedDimensions wrote: Putting the code in a template/function/lambda does not work because of the scopes which will be called when the main function exists. I think you might just be using the wrong kind of function. --- import std.stdio; // the

Re: Code repetition

2018-05-27 Thread Malte via Digitalmars-d-learn
On Sunday, 27 May 2018 at 06:47:38 UTC, IntegratedDimensions wrote: A string mixin is too messy since it treats the code as a string losing all syntax highlighting, etc. I'd love to have something like a template mixin where I can just do mixin template fooSetup(ret) { // setup stuff

Re: Code repetition

2018-05-27 Thread IntegratedDimensions via Digitalmars-d-learn
I guess I should have mentioned that basically this is like a C macro.

Code repetition

2018-05-27 Thread IntegratedDimensions via Digitalmars-d-learn
I have some code like void foo() { // setup stuff int x; scope(exit) something; // x = 34; } void foon() { // setup stuff int x; scope(exit) something; // } All the setup stuff is virtually identical in each foo. There are slight differences such