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: ndemmel
Subject: Re: flet, cl-flet, cl-letf in 24.3
Date: Sat, 27 Apr 2013 04:16:02 -0700 (PDT)
User-agent: G2/1.0

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? I can see how a lexical binding to a 
generalized place (not a variable) would not neccessarily make sense; is that 
what you mean? Otoh cl-flet does exactly that, for the special case of 
(symbol-function ...), or is that not how I should view it?

> 
> > however I wanted to make sure that is the case.
> 
> 
> 
> Even better in most cases is:
> 
> 
> 
>      (defvar my-enable-foo-advice nil)
> 
>      (defadvice foo (...)
> 
>        (if my-enable-foo-advice ... ...))
> 
> 
> 
> and then replace (flet ((foo ...)) ...)
> 
> with (let ((my-enable-foo-advice t)) ...)
> 

I see. In my case I was concerned with keeping legacy code working without 
changing much.

Thanks!
Niko


reply via email to

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