unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* flet + advised functions
@ 2011-03-08  6:47 Andreas Politz
  2011-03-08 19:38 ` PJ Weisberg
       [not found] ` <mailman.18.1299613165.4046.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 4+ messages in thread
From: Andreas Politz @ 2011-03-08  6:47 UTC (permalink / raw)
  To: help-gnu-emacs


I just discovered that `flet' does not work with (some form of)
advised functions, such that it doesn't restore the original
function.  I have found no references to this behaviour on the
net, no bug reports either.  The results are the same in
emacs22/24. I assume, it has been this way for a long time !?

(progn
  (unintern 'foo)
  (defun foo () 'defun)
  (defadvice foo (around foo activate)
    ad-do-it)
  (setq letf-save (symbol-function
                   ;;'ad-Orig-foo
                   'foo
                   ))
  (fset 'foo (lambda nil 'flet))
  (fset 'foo letf-save)
  (foo))

=> flet

-ap


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flet + advised functions
  2011-03-08  6:47 flet + advised functions Andreas Politz
@ 2011-03-08 19:38 ` PJ Weisberg
       [not found] ` <mailman.18.1299613165.4046.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 4+ messages in thread
From: PJ Weisberg @ 2011-03-08 19:38 UTC (permalink / raw)
  To: Andreas Politz; +Cc: help-gnu-emacs

On Mon, Mar 7, 2011 at 10:47 PM, Andreas Politz <politza@fh-trier.de> wrote:
>
> I just discovered that `flet' does not work with (some form of)
> advised functions, such that it doesn't restore the original
> function.  I have found no references to this behaviour on the
> net, no bug reports either.  The results are the same in
> emacs22/24. I assume, it has been this way for a long time !?
>
> (progn
>  (unintern 'foo)
>  (defun foo () 'defun)
>  (defadvice foo (around foo activate)
>    ad-do-it)
>  (setq letf-save (symbol-function
>                   ;;'ad-Orig-foo
>                   'foo
>                   ))
>  (fset 'foo (lambda nil 'flet))
>  (fset 'foo letf-save)
>  (foo))
>
> => flet
>
> -ap
>

This belongs in a bug-report, not on the help mailing list.

It looks like the problem is with symbol-function, not flet (since you
never actually use flet in the example).

'(unintern foo)' is also unnecessary; I'd remove it to avoid muddying
the waters.

(progn
 (defun foo () 'defun)
 (defadvice foo (around foo activate)
   ad-do-it)
 (setq letf-save (symbol-function
                  'foo
                  ))
 (fset 'foo (lambda nil 'fset))
 (fset 'foo letf-save)
 (foo))
=> fset

(symbol-function 'foo)
=> #[nil "\301\x18\302 \211\x10)\207" [ad-return-value nil ad-Orig-foo] 2
#("Advice doc string" 0 17 (ad-advice-info foo))]

I see  that the byte-compiled result of symbol-function doesn't
contain the symbol that it's supposed to return, but an un-advised
version does.

(progn
 (defun foo () 'defun)
 (setq letf-save (symbol-function
                  'foo
                  ))
 (fset 'foo (lambda nil 'fset))
 (fset 'foo letf-save)
 (byte-compile 'foo)
 (symbol-function 'foo))

=> #[nil "\300\207" [defun] 1]

-PJ



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flet + advised functions
       [not found] ` <mailman.18.1299613165.4046.help-gnu-emacs@gnu.org>
@ 2011-03-08 20:35   ` Andreas Politz
  2011-03-08 20:49     ` PJ Weisberg
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Politz @ 2011-03-08 20:35 UTC (permalink / raw)
  To: help-gnu-emacs

PJ Weisberg <pj@irregularexpressions.net> writes:

> On Mon, Mar 7, 2011 at 10:47 PM, Andreas Politz <politza@fh-trier.de> wrote:
>>
>> I just discovered that `flet' does not work with (some form of) [...]
>
> This belongs in a bug-report, not on the help mailing list.
>

Ok, done.  My surprise was such, that I considered this to be a feature.

-ap


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: flet + advised functions
  2011-03-08 20:35   ` Andreas Politz
@ 2011-03-08 20:49     ` PJ Weisberg
  0 siblings, 0 replies; 4+ messages in thread
From: PJ Weisberg @ 2011-03-08 20:49 UTC (permalink / raw)
  To: Andreas Politz; +Cc: help-gnu-emacs

On Tue, Mar 8, 2011 at 12:35 PM, Andreas Politz <politza@fh-trier.de> wrote:

> Ok, done.  My surprise was such, that I considered this to be a feature.
>
> -ap
>

If it is, then it's surprising enough that there's at least a bug in
the documentation. :-)

-PJ



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-08 20:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-08  6:47 flet + advised functions Andreas Politz
2011-03-08 19:38 ` PJ Weisberg
     [not found] ` <mailman.18.1299613165.4046.help-gnu-emacs@gnu.org>
2011-03-08 20:35   ` Andreas Politz
2011-03-08 20:49     ` PJ Weisberg

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).