You are here: Re: Function returning 2 arrays - which way to do so? « PHP Programming Language « IT news, forums, messages
Re: Function returning 2 arrays - which way to do so?

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация