help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defining functions within functions?


From: Carlos Konstanski
Subject: Re: Defining functions within functions?
Date: Tue, 24 May 2016 16:10:58 -0600

Am Dienstag, den 24.05.2016, 14:56 -0700 schrieb Drew Adams:
> > 
> > And I wanted to use the former variant, but it struck me as not
> > very
> > elegant.  As for the latter, I'm not sure I understand it exactly,
> > but
> > I'll give it some thought.
> > 
> > For now, I decided to go with lambdas, but also to sprinkle the
> > code
> > with comments.  Old-fashioned, but should do the jon in my case.
> A suggestion: Post a concrete example of what you need, and
> see what concrete suggestions you get.
> 
> Typically, this stuff is not complicated.  The first thing
> to do, IMO, is to determine whether you really need/want to
> do something special/complicated.  Why do you think you want
> a nested defun or other form of local function definition?

My 2 cents: as a common lisp propgrammer, I find two uses for
labels/flet:

- Recusrion. The wrapping code sets up the initial enviornment and then
calls the inner function where all the real work happens. In all other
languages you need two functions, but in lisp you can package the
entire thing into one form with an inner function.

- Arguments for free: If the flet is defined within the lexical scope
of some bindings, you can treat those bindings as "globals" and not
have to pass them into the function. I'm guessing this is what all the
let-over-lambda talk is about.

Both of these are valid uses of labels. Unless you have code
portability concerns, don't shy away from a package that gives emacs
lisp the same power as the other lisps.

Carlos



reply via email to

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