Last active
August 29, 2015 14:01
-
-
Save sprig/a3278af0172a306a0b7a to your computer and use it in GitHub Desktop.
Why (eval (list 'symbol))
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
(setq testvar nil) | |
nil | |
(defmacro testmacro () | |
(if testvar "OMG, I passed the test!") | |
(pp "I failed! damn!"))) | |
testmacro | |
(setq test-simple (testmacro)) | |
"I failed! damn!""\"I failed! damn!\"" | |
(setq test-eval (eval (list 'testmacro))) | |
"I failed! damn!""\"I failed! damn!\"" | |
;; :( the same... | |
(defun test-simple () | |
(testmacro)) | |
"I failed! damn!"test-simple | |
(defun test-eval () | |
(eval (list 'testmacro))) | |
test-eval | |
;; Already different, but here comes the magic: | |
(setq testvar t) | |
t | |
(test-simple) | |
"\"I failed! damn!\"" | |
(test-eval) | |
"OMG, I passed the test!""\"OMG, I passed the test!\"" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment