Last active
December 19, 2015 18:49
-
-
Save jordonbiondo/6001887 to your computer and use it in GitHub Desktop.
let vs cl-flet scope
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
(defvar foo 2) | |
(defun return-foo() | |
foo) | |
(defun just-call-return-foo() | |
(return-foo)) | |
(defadvice return-foo (around change-it activate) | |
"This let block redefines foo in the expansion of ad-do-it" | |
(let ((foo 10)) | |
ad-do-it)) | |
(defadvice just-call-return-foo (around change-baz activate) | |
"This flet block has no effect on the function just-call-return-foo" | |
(cl-flet ((just-call-return-foo () "hi")) | |
ad-do-it)) | |
(return-foo) ;; returns 10 | |
(just-call-return-foo) ;; returns 10, hoping for "hi" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment