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

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

Re: flet, cl-flet, cl-letf in 24.3


From: Pascal J. Bourguignon
Subject: Re: flet, cl-flet, cl-letf in 24.3
Date: Sat, 27 Apr 2013 13:46:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

ndemmel@gmail.com writes:

> On Monday, April 22, 2013 3:32:05 PM UTC+2, Stefan Monnier wrote:
>> > as reported here [5], this documentation does not really tell me what to do
>> 
>> > if I want to keep relying on the dynamic scoping of flet.  A brief google
>> 
>> > search [6] leads me to believe that
>> 
>> 
>> 
>> >     (cl-letf (((symbol-function 'foo) #'(lambda (...) ...))) ...) 
>> 
>> 
>> 
>> > is the suggested solution,
>> 
>> 
>> 
>> That's the case.
>
> Thanks!
>
>> 
>> > Does that always have dynamic scope?
>> 
>> How could it not?
>> 
>
> I'm not sure. What makes you say that? 

That's because it's not until run-time that the function slot of the
symbol foo is modified.  The _expression_ is evaluated at run-time.
Here we have a literal anonymous function, but it could be any
expression returning a function determined at run-time.

Therefore there's absolutely no way the compiler can know what (foo x)
means inside the cl-letf (apart from the fact that it's a function
call).

Also, since (symbol-function 'foo) is a global place, _while_ the cl-letf
is in effect, (foo x) will call your lambda even outside of the lexical
scope of the cl-letf.



> I can see how a lexical binding
> to a generalized place (not a variable) would not neccessarily make
> sense; is that what you mean? 

Indeed.



-- 
__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]