(require 'stdlib) ;; (multiple-value-bind (SYM SYM...) FORM BODY): collect multiple ;; return values. FORM must return a list; the BODY is then executed ;; with the first N elements of this list bound (`let'-style) to each ;; of the symbols SYM in turn. This is analogous to the Common Lisp ;; `multiple-value-bind' macro, using lists to simulate true multiple ;; return values. For compatibility, (values A B C) is a synonym for ;; (list A B C). ;; scheme calls this: receive (defmacro multiple-value-bind (vars form #!rest body) (let ((temp (gensym)) (n -1)) (list* 'let* (cons (list temp form) (mapcar (lambda (v) (list v (list 'nth (setq n (1+ n)) temp))) vars)) body))) (define values list) (define (env x) (values (1- x) x (1+ x))) (multiple-value-bind (a b c) (env 4) (print (list 'a= a 'b= b 'c= c)))