[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defining functions within functions?
From: |
Barry Margolin |
Subject: |
Re: Defining functions within functions? |
Date: |
Tue, 24 May 2016 10:33:37 -0400 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <864m9oj5cq.fsf@student.uu.se>,
Emanuel Berg <embe8573@student.uu.se> wrote:
> What do you mean by "additional arguments" tho?
> What I can see (?) the only thing replaced (not
> added) is the let binding, by the
> function name!
If you have a local function, it can access variables in the calling
function directly. If you move it out to a top-level function, you have
to pass those variables as arguments.
(defun foo1 (x)
(flet ((local-bar (y)
(+ x y)))
(local-bar 3)))
(defun foo2 (x)
(global-bar 3 x))
(defun global-bar (x y)
(+ x y))
And if the function being called needs to reassign the variable, you
need to do that in the caller if you use a top-level function.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?, Emanuel Berg, 2016/06/02
- Re: Defining functions within functions?,
Barry Margolin <=