out default argument of void

Caligo iteronvexor at gmail.com
Wed Jan 4 14:19:18 PST 2012


I have a function that looks something like this:

bool fun(double theta, out A a, out B b, out C c){  /* ... */ }

if fun() returns false, then nothing is supposed to be assigned to a,
b, c.  If it returns true, then values are assigned to a, b, c.  Also,
there are two ways to call fun():  If I'm interested in the return
value only, then

1. fun(theta);

otherwise,

2. fun(theta, a, b, c);

Obviously, method #1 won't work because there is no such thing as:

bool fun(double theta, out A a = void, out B b = void, out C c =
void){  /* ... */ }

is there?

So, I have to lose 'out' and use pointers instead:

bool fun(double theta, A* a = null, B* b = null, C* c = null){  /* ... */ }

I don't want to use a variadic function for this either because it's
not really a variadic function.

1. Are there any other solutions ?
2. Would it make sense to have 'out default argument of void' in D?


More information about the Digitalmars-d-learn mailing list