[Top][All Lists]

[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 12:15:18 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <address@hidden>,
 Emanuel Berg <address@hidden> wrote:

> Barry Margolin <address@hidden> writes:
> > 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.
> Right, I didn't think of that but actually it
> is even more confusing.
> It is more clear to call the function at top
> level, and pass it all it needs to do its job.
> > 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.
> "reassign the variable"?

(defun foo-local (a) 
  (flet ((bar ()
           (incf a)))


(defun foo-global (a)
  (setq a (bar a))
(defun bar (a)
  (+1 a))

Barry Margolin, address@hidden
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***

reply via email to

[Prev in Thread] Current Thread [Next in Thread]