Re: Quick help on version function parameter

2015-02-19 Thread via Digitalmars-d-learn
On Thursday, 19 February 2015 at 01:39:19 UTC, Jonathan Marler wrote: On Wednesday, 18 February 2015 at 23:49:26 UTC, Adam D. Ruppe wrote: I'd write a foo_impl which always takes a parameter. Then do the versioned foo() functions which just forward to it: void foo_impl(int x) { long function u

Re: Quick help on version function parameter

2015-02-18 Thread Jonathan Marler via Digitalmars-d-learn
On Wednesday, 18 February 2015 at 23:49:26 UTC, Adam D. Ruppe wrote: I'd write a foo_impl which always takes a parameter. Then do the versioned foo() functions which just forward to it: void foo_impl(int x) { long function using x here } version(globals) { int x; void foo() { foo_i

Re: Quick help on version function parameter

2015-02-18 Thread Adam D. Ruppe via Digitalmars-d-learn
I'd write a foo_impl which always takes a parameter. Then do the versioned foo() functions which just forward to it: void foo_impl(int x) { long function using x here } version(globals) { int x; void foo() { foo_impl(x); } } else { void foo(int x) { foo_impl(x); } } Minimal d

Quick help on version function parameter

2015-02-18 Thread Jonathan Marler via Digitalmars-d-learn
Does anyone know a good way to support versioned function parameters? Say, in one version I want a variable to be a global and in another I want it to be a parameter. version(GlobalVersion) { int x; void foo() { // A huge function that uses x } } else { void foo(int