Subject: Re: Ruby style
From: rpw3@rpw3.org (Rob Warnock)
Date: Fri, 06 Dec 2002 07:35:51 -0600
Newsgroups: comp.lang.lisp
Message-ID: <mtqdnbGupN0qOm2gXTWcoA@giganews.com>
Bruce Hoult  <bruce@hoult.org> wrote:
+---------------
|tfb@apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) wrote:
| > Perhaps he means something like the fact that you can't do this:
| >   (let* (((a b c) (values 1 2 3))
| >          (d (+ a b c))
| >          ((e f) (round d)))
| >     ...)
...
| e.g., the above in Dylan (with one value changed for better illustration):
| 
| begin
|   let (a, b, c) = values(1.8, 2, 3);
|   let d = a + b + c;
|   let (e, f) = round(d);
|   format-out("%= = %= + %=\n", d, e, f);
| end
| 
| =>
| 6.8d0 = 7 + -0.2d0
| 
| Scheme actually comes annoyingly close to this if you use "define" other 
| than at the toplevel.  Except that it dosn't do multiple values.
+---------------

PLT Scheme (MzScheme) has "let-values", "let*-values", and "letrec-values",
so the originally-proposed code is fine [assuming a tiny change to the
syntax of the second binding subform]:

      (let*-values (((a b c) (values 1 2 3))
                    ((d) (+ a b c))	; requires parens around var list
                    ((e f) (round d)))	; BUG!
        ...)

Unfortunately, Scheme's "round" only returns one value!!  :-( 

(...because Scheme requires strict matching of the arity of
a continuation with the number of values returned through it,
unlike CL's more-convenient silent dropping of excess values.)


-Rob

-----
Rob Warnock, PP-ASEL-IA		<rpw3@rpw3.org>
627 26th Avenue			<URL:http://www.rpw3.org/>
San Mateo, CA 94403		(650)572-2607