Created
March 10, 2012 01:26
-
-
Save manuel/2009588 to your computer and use it in GitHub Desktop.
Hygienic swap macro in EdgeLisp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (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