Out parameters and initialization

Unknown W. Brackets unknown at simplemachines.org
Sun Feb 26 13:49:27 PST 2006


Obviously that has nothing to do with what I meant.

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.

Currently, a workaround would be:

int foo(out C x)
{
    C dummy1, dummy2;
    return foo(x, dummy1, dummy2);
}

But this really is going to the side a bit of the topic.

-[Unknown]


> Unknown W. Brackets wrote:
>> I'm thinking from the "in-side".  In my mind, if I leave off an out or 
>> inout parameter, I want the result to go nowhere (but might still 
>> expect the variable to exist in the function.)  I don't see how this 
>> isn't logical, but I can understand how you'd disagree.
> 
> If you don't want a result the solution is easy:
> 
> void func(in int x = 7)
> 
> func();
> All conditions satisfied:
> * result is going nowhere
> * var exists in a function
> * it's value is 7
> 
> The point is: if you don't need a result, then what you probably want is 
> in and not out/inout. Out is for something else.



More information about the Digitalmars-d-bugs mailing list