This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: values (Re: R5RS)
- To: guile at sourceware dot cygnus dot com
- Subject: Re: values (Re: R5RS)
- From: Ole Myren Rohne <ole dot rohne at cern dot ch>
- Date: 01 Mar 2000 10:29:44 +0100
- References: <Pine.GSO.4.10.10002261909270.28535-100000@sundial> <20000227062836.A5387@206.31.63.15> <hhaekm4i0d.fsf@geniry.i-did-not-set--mail-host-address--so-shoot-me> <s3wvnqbl9u.fsf_-_@verisity.com> <hhln4686sq.fsf@geniry.i-did-not-set--mail-host-address--so-shoot-me> <m3u2iut0ho.fsf@savonarola.red-bean.com> <20000228021317.A20323@206.31.63.15> <m39005t5h1.fsf@savonarola.red-bean.com> <20000229060756.A22531@206.31.63.15> <20000229080236.A23088@206.31.63.15>
"C. Ray C." <crayc@206.31.63.15> writes:
> Here is a simple implementation of the list-let I proposed:
>
> (define-macro (list-let vars lst . body)
> `(apply (lambda ,vars ,@body) ,lst))
>
And here are some simple implementations of multiple-value-bind and a few
other CL'isms:
;;; multiple-value-bind
(define-macro (let-values var-list values-form . form*)
`(call-with-values
(lambda () ,values-form)
(lambda ,var-list ,@form*)))
;;; values-list
(define (list->values list)
(apply values list))
;;; multiple-value-list
(define (values->list values-form)
(call-with-values
(lambda () values-form)
list))
;;; We have to construct a list for this one, yuck.
;;; Why doesn't (values 1 (values 2 3) 4) => #<values 1 2 3 4> anyway?
;;; multiple-value-call
(define (apply-to-values function . form*)
(apply function (apply append (map multiple-value-list form*))))
---
Some random thoughts/questions concerning values...
Someone indicated that guile values/call-with-values are not R5RS
conformant. Is this because call-with-values creates a continuation
that accepts a single #<values ...> argument rather than multiple
arguments?
guile> (define t
(call-with-current-continuation
(lambda (return)
(call-with-values
(lambda ()
(call-with-current-continuation
(lambda (cont)
(return cont))))
(lambda (x y z) y)))))
guile> t
#<continuation 1155 @ 807cc48>
guile> (t 1 2 3)
standard input:176:1: In expression (t 1 2 ...):
standard input:176:1: Wrong number of arguments to #<continuation 1155 @ 807cc48>
ABORT: (wrong-number-of-args)
guile> (t (values 1 2 3))
guile> t
2
What would it cost to support multiple arguments continuations and use
them to implement multiple values?
Can anyone think of a reason to include m-a-c (except for possibly
strict R5RS compliance)?
Can anyone comment on possible efficiency issues of m-a-c versus
explicit #<values ...> objects?
In spite of R5RS saying:
"The effect of passing no value or more than
one value to continuations that were not created by
call-with-values is unspecified",
having continuations explicitly _ignore_ superfluous arguments would
allow for a set of CL'isms:
(floor 1.5 1) => 1, 0.5
(* 10 (floor 1.5 1)) => 10
Regards,
Ole Myren Røhne