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

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

Re: sending function arguments to recursive function calls


From: Pascal J. Bourguignon
Subject: Re: sending function arguments to recursive function calls
Date: Tue, 07 May 2013 16:32:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Gauthier Östervall <gauthier@ostervall.se> writes:

> On Sat, May 4, 2013 at 5:30 PM, Drew Adams <drew.adams@oracle.com> wrote:
>> The key to the puzzle is this little declaration in the first comment of the
>> file:
>>
>> ;;; face-remap.el --- Functions for ... -*- lexical-binding: t -*-
>>
>> That `lexical-binding t' tells Emacs that the code in this file is meant to 
>> be
>> understood with the variable `lexical-binding' bound to t (locally).
>
> Thanks for the kind words and the explanation. I do not feel very
> confident about having a function that relies on a file scope setting
> of lexical-binding, which as in this case happens 300 lines earlier.
> Wouldn't it be better to have functions that work whatever the value
> of lexical-binding, if possible?
>
>> An alternative to using a lexical binding here would be to simply use this:
>>
>>  `(lambda () (interactive) (text-scale-adjust (abs ',inc)))
>
> If this alternative works whatever lexical-binding, it seems superior
> to me. Isn't it?

No, it is inferior.

Here, you have to duplicate the code of the function for each occurence.

With closures (lexical binding) you only need to duplicate the enclosed
environment, the code of the function being the same for all the
closures.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
A bad day in () is better than a good day in {}.




reply via email to

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