about inner function

Discussion of Common Lisp

about inner function

Postby 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
:? :? :?
andyqu
 
Posts: 1
Joined: Wed May 02, 2012 4:39 am

Re: about inner function

Postby 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))))
User avatar
nuntius
 
Posts: 500
Joined: Sat Aug 09, 2008 10:44 am
Location: Burlington, MA


Return to Common Lisp

Who is online

Users browsing this forum: Bing [Bot] and 4 guests