From: Luke Graham Date: 2005-05-24T15:26:38+09:00 Subject: Re: Multiple return and parallel assignement On 5/24/05, Michael Ulm wrote: > Robert Klemme wrote: > > Michael Ulm wrote: > > > >>Robert Klemme wrote: > >> > >>>Ralph "PJPizza" Siegler wrote: > >>> > >>> > >>>>On Sat, May 21, 2005 at 01:30:13AM +0900, James Britt wrote: > >>>> > >>>> > >>>>>Eric Mahurin wrote: > >>>>> > >>>>> > >>>>>>I've never quite understood why most languages inherently > >>>>>>support returning only a single value > >>>>> > >>>>> > >>>>>Conceptual elegance? > >>>>> > >>>>>Seems cleaner to say that every expression returns an object, > >>>>>though that the object may be a container for other objects, > >>>>>rather than assert that expressions may return an unknown number > >>>>>of objects > >>>>> > >>>>> > >>>>>James > >>>>> > >>>> > >>>>I also think it may be from the original mathematical idea of a > >>>>"function', which only has 1 output value for a given set of inputs, > >>> > >>> > >>>Mathematical functions are in no way limited to yielding a single > >>>output value. > >>> > >> > >> > >>But they are. A (mathematical) function f: M -> N from a set M to a > >>set N is usually defined as a subset of M x N such that for each > >>element m in M there exists exactly one element n in N such that > >>the pair (m, n) is in the subset; one then writes f(m) = n. > >> > > > > > > So what? M can be A x B x C and N can be D x E - or whatever. > > > > > >>>>which 3rd generation programming languages adopted as paradigm. > >>>>With multiple return values, more in the mindset of a "relation", > >>>>an n to m mapping > >>> > >>> > >>>That's what a mathematical function is basically. Don't let sin, > >>>cos, max, min etc. fool you on this one. :-) > >> > >>Maybe you are thinking of vector valued functions, where the return > >>value is a vector? In that case, one still has only one return value > >>(the vector) which in turn contains other elements. This is very > >>similar to returning an array in ruby. > > > > > > With your reasoning there is also just a single input value for math > > functions. So either functions have a single input and a single output > > value, or multiple at both ends. But claiming that there can be multiple > > input values but only a single output value is at least a bit dishonest > > IMHO. > > > > Indeed, strictly speaking, a mathematical function can only have one > input value. Mathematically, the notation f(x, y) is just a shorthand > for f([x, y]). If Kernigan and Richie had paid more attention at > math class we would have declarations like > > (float, float) transform (float, float) > > in C, and the world would be a better place for it :-) Am I the only one who feels like a curry now? -- spooq