Re: Function returning 2 arrays - which way to do so?
- From: Logos <tyler.style@xxxxxxxxx>
- Date: Wed, 9 Jan 2008 09:55:11 -0800 (PST)
On Jan 7, 11:23 pm, Tim Roberts <t...@xxxxxxxxx> wrote:
Logos <tyler.st...@xxxxxxxxx> 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...@xxxxxxxxx
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.
.
- References:
- Function returning 2 arrays - which way to do so?
- From: jodleren
- Re: Function returning 2 arrays - which way to do so?
- From: Michael Fesser
- Re: Function returning 2 arrays - which way to do so?
- From: Logos
- Re: Function returning 2 arrays - which way to do so?
- From: Tim Roberts
- Function returning 2 arrays - which way to do so?
- Prev by Date: Re: PHP Basics
- Next by Date: Re: Difference between storing files on folder and in mysql db
- Previous by thread: Re: Function returning 2 arrays - which way to do so?
- Next by thread: Re: Function returning 2 arrays - which way to do so?
- Index(es):