[Top][All Lists]

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

Re: Closures in Emacs and their usage scenarios.

From: Marcin Borkowski
Subject: Re: Closures in Emacs and their usage scenarios.
Date: Tue, 12 Oct 2021 07:29:07 +0200
User-agent: mu4e 1.1.0; emacs 28.0.50

On 2021-10-12, at 01:16, Emanuel Berg via Users list for the GNU Emacs text 
editor <> wrote:

> Marcin Borkowski wrote:
>> Yet another use (which of course - technically - is again
>> a variant of the same thing) is generating a closure whose
>> behavior depends on the argument of the function that
>> defines it.
> Not following?

A function defines (and possibly returns) a closure.  The behavior of
the closure depends on the value of an argument to that function.
Different arguments yield different functions.  Just like the example

>> (defun negate (fun)
>>   "Return a function returning the logical opposite of FUN."
>>   (lambda (&rest args)
>>     (not (apply fun args))))
> Yes, I remember, no, I know you can do a lot with `lambda'
> (anonymous function I believe :)), I mean just the
>   (let ((...) ...)
>     (defun ... )
>     ...
>     )
> syntax Here are the 1 + a use cases I know of, where a -> 1.

What's the difference?  Doesn't `defun` contain an implicit `let' with
the arguments?  IOW, function arguments are much like local variables.


Marcin Borkowski

reply via email to

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