Re: More than one values returned?
| From: | Nick Stinemates | Date: | Wed, 20 Feb 2008 05:24:10 +0000 |
| Subject: | Re: More than one values returned? | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-269689@lists.php.net to get a copy of this message | ||
Nathan Nobbe wrote:
> On Feb 19, 2008 11:52 PM, Greg Donald <gdonald@gmail.com> wrote:
>
>
>> On Feb 19, 2008 9:27 PM, Nick Stinemates <nick@stinemates.org> wrote:
>>
>>> Support != good design habits.
>>>
>> So you presume to have better design habits than the many language
>> designers who implemented parallel assignment in their respective
>> language? Right.
>>
>>
>>
>> http://en.wikipedia.org/wiki/Assignment_%28computer_science%29#Parallel_assignment
>>
>>
>>> Please read my other post which explains
>>> the reasoning.
>>>
>> Your "reasoning" is shit.
>>
>
>
> dAAmn dude :D i agree though, being able to return multiple values from
> a function has nothing to do with good or bad design of a language. in fact
> if a language doesnt have support for it, likely it would not be in
> widespread
> use as is php.
> and also, nick, for the record, it has nothing to do with being strongly or
> weakly typed. take a look at c++, java, and .net; all strongly typed and
> all
> have pass-by-reference; thats what its for ;) and i dont want to act like
> the
> first person who said it because, C.R. Vegelin, said it first in this
> thread.
> (sorry ive been way busy lately :))
> but to op, yes, you can of course return an aggregate structure, but there
> are many times where it is appropriate to use pass-by-reference instead,
> because,
> read:
> thats what the mechanism is designed for :)
>
> let me furnish you with the most common example i can think of.
> suppose you have a method that is returning a boolean status, but you want
> to get some data back out of it as well. then you have it return a boolean
> value, and toss a pass-by-reference parameter in there,
> eg.
>
> /**
> * do some crazy crap to some dudes account
> */
> function doCrazyCrapToAccount($accountId, &$someCrazyNewCrapOnTheAccount) {
> $wasSuccess = false;
> /// potentially alter $wasSuccess ...
> /// drop something meaningful in $someCrazyNewCrapOnTheAccount ...
> return $wasSuccess;
> }
>
> // then
> $accountId = 5;
> $crazyNewCrapOnAccount = null;
> if(doCrazyCrapToAccount($accountId, $crazyNewCrapOnAccount)) {
> echo $crazyNewCrapOnAccount;
> }
>
> and i was doing that in c++ back in o, 99' so yeah; nothing to do w/
> loose typing, totally relevant; and thats technically how you return
> multiple
> values from a function, because lets face it; an aggregate is well, one
> thing,
> that just so happens to contain things, but again; its just one thing ;)
>
> -nathan
>
>
Not once did I knock By Reference value passing or pointers.
I said, simply, returning an array of objects was usually an indication
of poor design.
--
==================
Nick Stinemates (nick@stinemates.org)
http://nick.stinemates.org
AIM: Nick Stinemates
MSN: nickstinemates@hotmail.com
Yahoo: nickstinemates@yahoo.com
==================