Multiple return values 
Author Message
 Multiple return values

Quote:

>     Isn't the usefullness of having multiple return values
>for functions basically diminished by not allowing the
>returned values to be assigned to previously created
>variables?
>IMHO, this is absurd.  In order to use multiple return
>values, I must create new temporary variables.

Binding is better than assignment. Perhaps that is the
rationale.

The work-around is to define your own syntax. Call it
MULTIPLE-VALUE-SETQ.

--

(503) 264-9309, FAX: (503) 264-3375



Tue, 14 Apr 1998 03:00:00 GMT  
 Multiple return values
     Isn't the usefullness of having multiple return values
for functions basically diminished by not allowing the
returned values to be assigned to previously created
variables?

For example:

define variable (h, i) = (2, 3);
define method some-method () => (a, b);
     values (b, a);
end;
// The following isn't allowed!
(h, i) := some-method();   // error
// Insead one must always create new temporary variables in
// order to use the multiple values returned by some-method
let (t1, t2) = some-method ();
h := t1;
i := t2;

IMHO, this is absurd.  In order to use multiple return
values, I must create new temporary variables.  Is there a
work-around?  How is this issue being addressed by the
dylan development team?

Regards,
Wolfgang Ziller



Tue, 14 Apr 1998 03:00:00 GMT  
 Multiple return values

Quote:

>      Isn't the usefullness of having multiple return values
> for functions basically diminished by not allowing the
> returned values to be assigned to previously created
> variables?

Well, I sort of agree. However, I thought you could always "let" with the
same variable name as many times as you like in the same scope, so you
could:

  let x := #"foo";
  let y := #"bar";
  let (x, y) := multivalue-function();

If so, then the only difference between single and multiple return values
is the use of the "let" keyword, which seems a little more formal but
doesn't seem to stand out as a problem to me.

Of course, if I'm wrong about "let" scope rules, then I think "(x, y) :=
foo()" should be added to the language unless there is a strong argument
against it.

--
Chris Page        | Internet chain letters, adverti{*filter*}ts and SPAMs suck...
Don't Panic!      |



Wed, 15 Apr 1998 03:00:00 GMT  
 Multiple return values

Quote:

>   let x := #"foo";
>   let y := #"bar";
>   let (x, y) := multivalue-function();

Oops: ":=" should be "=".

--
Chris Page        | Internet chain letters, adverti{*filter*}ts and SPAMs suck...
Don't Panic!      |



Wed, 15 Apr 1998 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ???Eiffel idiom for multiple return values???

2. Tuples, iterators, and multiple return values in Eiffel?

3. Multiple return values

4. multiple return values

5. Newbie on multiple return values

6. multiple return values for functions

7. Multiple return values

8. 1st-class method closures (was Re: Multiple return values)

9. C-interface and multiple return values

10. multiple Return values

11. Destructuring / pattern-matching (was: Multiple return values)

12. Destructuring / pattern-matching (was: Multiple return values)

 

 
Powered by phpBB® Forum Software