Skip to main content
Improve formatting; simplify tags
Source Link
Basil
  • 12.8k
  • 45
  • 71

In the following code the function foofoo calls the outer f2f2 function. How to make it call the anonymous function bound within the letlet?

(defun f2() (message "outer f2")) (defun foo() (f2)) (let ((f2 #'(lambda () (message "inner f2")))) (foo)) ;; The foo does not call the f2 in the let. ie. prints "outer f2" 
(defun f2 () (message "outer f2")) (defun foo () (f2)) (let ((f2 (lambda () (message "inner f2")))) (foo)) ;; `foo' does not call `f2' in the `let', i.e. prints "outer f2" 

In the following code the function foo calls the outer f2 function. How to make it call the anonymous function bound within the let?

(defun f2() (message "outer f2")) (defun foo() (f2)) (let ((f2 #'(lambda () (message "inner f2")))) (foo)) ;; The foo does not call the f2 in the let. ie. prints "outer f2" 

In the following code the function foo calls the outer f2 function. How to make it call the anonymous function bound within the let?

(defun f2 () (message "outer f2")) (defun foo () (f2)) (let ((f2 (lambda () (message "inner f2")))) (foo)) ;; `foo' does not call `f2' in the `let', i.e. prints "outer f2" 
Source Link

How to temporarily change the definition of a function?

In the following code the function foo calls the outer f2 function. How to make it call the anonymous function bound within the let?

(defun f2() (message "outer f2")) (defun foo() (f2)) (let ((f2 #'(lambda () (message "inner f2")))) (foo)) ;; The foo does not call the f2 in the let. ie. prints "outer f2"