Jonathan M Davis <[email protected]> wrote:
> On Friday, March 02, 2012 09:53:19 kennytm wrote:
>> You can just chain with
>> 
>>     return doSomething(findSplit(haystack, needle)[0]);
>> 
>> if you just need the return value. Compare with 'out':
>> 
>>     R4 ignored;
>>     R5 ignored2;
>>     return doSomething(findSplit(haystack, needle, ignored, ignored2));
>> 
>> How do you chain with _partial_ amount of return values with 'out'?
> 
> If the function uses out, then you can chain the return value without losing 
> the values which were assigned to the out arguments, but if you have a tuple, 
> and you select one of the elements in the tuple to chain, you lose the 
> others. 
> The only way to get _all_ of the values in the tuple is to assign the tuple 
> to 
> a variable, in which case, you can't chain at all.
> 
> - Jonathan M Davis

I see what you mean. However, this is useful only when you know one of the
return value is special, and make the rest 'out' parameters, e.g.

    File openFile(string fn, string mode, out ErrorCode errCode);

because the API designer know people seldom focus on the 'errCode'. But if
not all return values are considered unimportant (such as findSplit and
remquo), randomly making some of them as the 'out' parameter just make the
normal use cases more messy.

Besides, you can't use type inference with 'out' parameters. You don't
actually know the types R4 and R5 in my findSplit2 example.

Reply via email to