[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RECEIVE vs LET-VALUES



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.

-- 
======  John David Stone - Lecturer in Computer Science and Philosophy  =====
==============  Manager of the Mathematics Local-Area Network  ==============
==============  Grinnell College - Grinnell, Iowa 50112 - USA  ==============
========  stone@xxxxxxxxxxxxxxx - http://www.cs.grinnell.edu/~stone/  =======