Last active
June 4, 2019 15:25
-
-
Save Bronsa/fa02d5bdebccba36c709683406dac0f7 to your computer and use it in GitHub Desktop.
This file contains 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
(defun gensymify (body &optional (mappings (make-hash-table :test #'equal))) | |
(mapcar | |
(lambda (el) | |
(cond | |
((listp el) | |
(gensymify el mappings)) | |
((and (symbolp el) | |
(not (symbol-package el))) | |
(let* ((n (symbol-name el)) | |
(s (gethash n mappings))) | |
(or s (let* ((g (gensym))) | |
(setf (gethash n mappings) g) | |
g)))) | |
(t el))) | |
body)) | |
(set-dispatch-macro-character #\# #\` | |
(lambda (stream char n) | |
(declare (ignore char n)) | |
(let ((body (list (quote quote) (read stream t nil t)))) | |
(gensymify body)))) | |
(eval #`(let ((#:a 1)) #:a)) ;; => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment