about inner function

Discussion of Common Lisp
Post Reply
andyqu
Posts: 1
Joined: Wed May 02, 2012 4:39 am

about inner function

Post by andyqu » Fri May 11, 2012 1:29 am

Can an inner function B, which is inside function A, access variables of A? I searched on google, but found little information about this
:? :? :?

nuntius
Posts: 538
Joined: Sat Aug 09, 2008 10:44 am
Location: Newton, MA

Re: about inner function

Post by nuntius » Fri May 11, 2012 8:29 am

Try the following in a CL implementation.

Code: Select all

(defun test (x)
  (let ((a 2))
    (flet ((f (y) (+ a y x)))
      (f x))))

Post Reply