Re: RECEIVE vs LET-VALUES
Lars Thomas Hansen 02 Jul 1999 18:41 UTC
John David Stone writes:
>Lars Thomas Hansen writes:
>
> > A definition of LET-VALUES that is compatible with the MzScheme syntax
> > and that accomplishes the same as RECEIVE is easily defined, however:
> >
> > (define-syntax LET-VALUES
> > (syntax-rules ()
> > ((LET-VALUES (?variables ?expr) ?body1 ?body2 ...)
> > (receive ?variables ?expr ?body1 ?body2 ...))))
>
> Actually, the functionality doesn't quite match, since RECEIVE can
>also accommodate variable-arity formals. For instance, you can define a
>very general kind of procedure compostion thus:
>
> (define (compose outer inner)
> (lambda arguments
> (receive intermediates (apply inner arguments)
> (apply outer intermediates))))
>
>Both OUTER and INNER can have any arity and return any number of values.
I'm puzzled. By design, my macro for LET-VALUES does not require the
pattern ?VARIABLES to be a list; it can be a single identifier or an
improper list. Thus:
(define (compose outer inner)
(lambda arguments
(let-values (intermediates (apply inner arguments))
(apply outer intermediates))))
expands into your code above. Is there a subtlety I'm missing?
--lars