[Top][All Lists]

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

Re: Defining functions within functions?

From: Marcin Borkowski
Subject: Re: Defining functions within functions?
Date: Wed, 25 May 2016 08:21:44 +0200
User-agent: mu4e 0.9.16; emacs

On 2016-05-25, at 00:10, Carlos Konstanski <> 

> 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.

That I don't need.

> - 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.

And those I do use.

> 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.

If you mean (require 'cl-lib), I do it anyway.  And if /I/ didn't,
request.el does.

> Carlos


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

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