Subject: Re: passing formal arguments to scheme lambda functions?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 2000/05/08
Newsgroups: comp.lang.scheme
Message-ID: <8f5u38$8hm8r$1@fido.engr.sgi.com>
Daniel Burrows  <Daniel_Burrows@brown.edu> wrote:
+---------------
|   If it is [really what he needs to do], though, a macro like
| (define-macro swap!
|   (lambda (a b) `(let ((tmp ,a)) (set! ,a ,b) (set! ,b tmp))))
+---------------

But don't forget unwanted variable capture. This would be safer, I think:

  (define-macro swap!
    (lambda (a b)
      (let ((tmpname (gensym)))
        `(let ((,tmpname ,a)) (set! ,a ,b) (set! ,b ,tmpname)))))


-Rob

-----
Rob Warnock, 41L-955		rpw3@sgi.com
Applied Networking		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043