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 x)
{
// A huge function that uses x (same code as
GlobalVersion)
}
}
The problem with this is that the code is duplicated. Is there a
way to do this versioning without having 2 copies of the same
function body? The following definitely does not work:
version(GlobalVersion)
{
int x;
void foo()
} else {
void foo(int x)
}
{
// A huge function that uses x
}