|
Posted by Logos on 01/09/08 17:55
On Jan 7, 11:23 pm, Tim Roberts <t...@probo.com> wrote:
> Logos <tyler.st...@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, t...@probo.com
> Providenza & Boekelheide, Inc.
Well, I'll admit to a C background.
However, if you're going to offer a critique I think it's only fair to
report which solution you think best & why, no? We have several
options for things being returned :)
IMHO, I think this is one of those stylistic things that really
doesn't have a best answer. It doesn't really impact performance in
any way - all that it impacts is *how the coder* interacts with the
code.
[Back to original message]
|