Re: More than one values returned?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Feb 19, 2008 11:52 PM, Greg Donald <gdonald@xxxxxxxxx> wrote:

> On Feb 19, 2008 9:27 PM, Nick Stinemates <nick@xxxxxxxxxxxxxx> 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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux