Skip to content

Instantly share code, notes, and snippets.

@sprig
Last active August 29, 2015 14:01
Show Gist options
  • Save sprig/a3278af0172a306a0b7a to your computer and use it in GitHub Desktop.
Save sprig/a3278af0172a306a0b7a to your computer and use it in GitHub Desktop.
Why (eval (list 'symbol))
(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