> -----Original Message-----
> From: Nathan Rixham [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, February 19, 2008 5:17 AM
> To: [email protected]
> Subject: Re: [PHP] More than one values returned?
>
> Robert Cummings wrote:
> > On Mon, 2008-02-18 at 21:09 -0600, Larry Garfield wrote:
> >> On Monday 18 February 2008, Nick Stinemates wrote:
> >>
> >>>>> I have found, however, that if I ever need to return /multiple/
> values,
> >>>>> it's usually because of bad design and/or the lack of proper
> >>>>> encapsulation.
> >>>> You mean you've never had a function like getCoordinates()? Or
> >>>> getUsers(), or any other of a zillion perfectly valid and reasonable
> >>>> functions that return multiple values as an array? Wow, how odd!
> >>>>
> >>>> Cheers,
> >>>> Rob.
> >>> getCoordinates() would return a Point object
> >>> getUsers() would return a Group object...
> >>>
> >>> Not rocket science ;)
> >> I wouldn't consider an array of user objects to be "multiple things". I
> >> consider it a single aggregate thing, and return arrays all the time.
> That's
> >> conceptually different from wanting two separate return values from a
> >> function, which is indeed conceptually icky.
> >
> > Yes, an aggregate is comprised of multiple things usually. Hence when
> > decomposing the concept you are indeed returning multiple values-- both
> > points of view are valid. If you receive a parcel of 100 pens. I can
> > say, "has the parcel arrived yet" (one entity) or "have the pens arrived
> > yet" (multiple entities).
> >
> > At any rate, the O.P. wanted to return multiple values called $x and $y.
> > It seems quite reasonable to assume he was returning something akin to
> > coordinates but didn't know how to do so by binding them in an
> > aggregating structure such as an array, or if you wish, an object.
> >
> > Cheers,
> > Rob.
>
> seriously, whats wrong with returning an array? half the standard php
> functions return array's, therefore at least half of php has been
> designed badly..?
>
> ps: when working with co-ordinates / GIS data you should really be using
> wkb data instead, it's much faster. [unpack]
>
So returning multiple values is a bad thing? How about Matlab for which it is
such a common thing to use multiple return values, and they even have names?
function [x, y] = myvectorfun(A, t)
x = A*cos(t);
y = A*sin(t);
end
Regards,
Rob
Andrés Robinet | Lead Developer | BESTPLACE CORPORATION
5100 Bayview Drive 206, Royal Lauderdale Landings, Fort Lauderdale, FL 33308 |
TEL 954-607-4207 | FAX 954-337-2695 |
Email: [EMAIL PROTECTED] | MSN Chat: [EMAIL PROTECTED] | SKYPE: bestplace |
Web: bestplace.biz | Web: seo-diy.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php