unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: ndemmel@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Re: flet, cl-flet, cl-letf in 24.3
Date: Sat, 27 Apr 2013 04:16:02 -0700 (PDT)	[thread overview]
Message-ID: <098b3b26-6cfa-478b-8870-7a7bdb806611@googlegroups.com> (raw)
In-Reply-To: <mailman.24438.1366637539.855.help-gnu-emacs@gnu.org>

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


  parent reply	other threads:[~2013-04-27 11:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-21  7:04 flet, cl-flet, cl-letf in 24.3 ndemmel
2013-04-21  7:41 ` Drew Adams
     [not found] ` <mailman.24402.1366530089.855.help-gnu-emacs@gnu.org>
2013-04-21  9:49   ` ndemmel
2013-04-21 16:07     ` Drew Adams
2013-04-22 13:32     ` Stefan Monnier
2013-04-22 15:09       ` Andreas Röhler
     [not found]     ` <mailman.24438.1366637539.855.help-gnu-emacs@gnu.org>
2013-04-27 11:16       ` ndemmel [this message]
2013-04-27 11:46         ` Pascal J. Bourguignon
2013-04-27 13:52         ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=098b3b26-6cfa-478b-8870-7a7bdb806611@googlegroups.com \
    --to=ndemmel@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).