Created
September 12, 2017 06:08
-
-
Save andlys/70f563da69c964721194ad2cdf36fba9 to your computer and use it in GitHub Desktop.
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 nth-expr (n &rest args) | |
(let ((g (gensym))) | |
`(let ((,g (1- ,n))) | |
(eval (nth ,g ',args))))) ; TODO: make this work without eval function | |
(defun watch () (print 'evaluated!)) | |
(let ((n 2)) | |
(macroexpand-1 '(nth-expr n (watch) (+ 1 3) 'value))) | |
(let ((n 2)) | |
(nth-expr n (watch) (+ 1 3) 'value)) | |
; => 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment