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