|
Posted by Tim Roberts on 01/08/08 06:23
Logos <tyler.style@gmail.com> wrote:
>
>I'll second this one. Passing in both arrays by reference is clean &
>tidy, and a commonly accepted way for a function to 'return' more than
>one value.
That's true in C and C++, but only because there's no way to return several
things at once.
There are two issues with the reference solution. First, it requires the
caller to allocate arrays first, and then pass those arrays to the
function. In many cases, that's not natural. Second, it creates a high
degree of linkage between the callee and caller, which again may not be
natural.
Now, these are both highly philosophical issues, but there is good sense in
adapting a policy that things to be returned should always be "returned",
rather than by modifying in/out parameters.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
[Back to original message]
|