Skip to content

Instantly share code, notes, and snippets.

@manuel
Created March 10, 2012 01:26
Show Gist options
  • Select an option

  • Save manuel/2009588 to your computer and use it in GitHub Desktop.

Select an option

Save manuel/2009588 to your computer and use it in GitHub Desktop.
Hygienic swap macro in EdgeLisp
(defmacro swap (a b)
#`(let ((tmp ,b))
(setq ,b ,a)
(setq ,a tmp)))
(let ((x 1) (tmp 2))
(swap x tmp)
(assert (and (= x 2) (= tmp 1)))
(swap tmp x)
(assert (and (= x 1) (= tmp 2))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment