Out parameters and initialization
Ivan Senji
ivan.senji_REMOVE_ at _THIS__gmail.com
Sun Feb 26 14:03:47 PST 2006
Unknown W. Brackets wrote:
> Obviously that has nothing to do with what I meant.
Uh, sorry I'm tired.
>
> Consider:
>
> int foo(out C x, out C y, out C z);
>
> It is possible I may not want to specify a y or a z. I may however
> still want the return value and x. In other parts of my code, I may
> want x and y, or all three. Only in some places will I not want z or y.
>
> You clearly misunderstood me. Using in has absolutely nothing to do
> with this.
I see that now:
>
> Currently, a workaround would be:
>
> int foo(out C x)
> {
> C dummy1, dummy2;
> return foo(x, dummy1, dummy2);
> }
No: a workaround would be:
private int dummy1, dummy2;
void foo(out int x = dummy1, out int y = dummy2, out int z = dummy3){...}
int foo(out C x)
{
return foo(x);
}
It complicates library code just a little but simplifies users code.
>
> But this really is going to the side a bit of the topic.
I thought the topic was initialization of out parameters.
More information about the Digitalmars-d-bugs
mailing list