unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13023: 24.3.50; lexical binding does not work within defadvice
@ 2012-11-28 16:17 Christopher Schmidt
  2012-11-29  4:32 ` Stefan Monnier
  2016-02-02 18:35 ` Marcin Borkowski
  0 siblings, 2 replies; 11+ messages in thread
From: Christopher Schmidt @ 2012-11-28 16:17 UTC (permalink / raw)
  To: 13023

    ;; -*- lexical-binding: t -*-

    (funcall (let ((rms "works"))
               (lambda ()
                 (message "lex-bind %s" rms))))

    (defun asdf (b) (funcall b))

    (defadvice asdf (before rms (b) activate)
      (setf b (let ((abc 1) (b b)) (lambda () (print abc) (funcall b)))))

    (asdf 'ding)

I think this code should work fine.  It doesn't work with trunk and
emacs-24, though:

    Load test.elc? (y or n)  y
    Loading test.elc...
    lex-bind works
    Load error for test.elc:
    (void-variable abc)

        Christopher





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-28 16:17 bug#13023: 24.3.50; lexical binding does not work within defadvice Christopher Schmidt
@ 2012-11-29  4:32 ` Stefan Monnier
  2012-11-29 22:50   ` Richard Stallman
  2016-02-02 18:35 ` Marcin Borkowski
  1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-11-29  4:32 UTC (permalink / raw)
  To: 13023

>     ;; -*- lexical-binding: t -*-
>     (funcall (let ((rms "works"))
>                (lambda ()
>                  (message "lex-bind %s" rms))))

>     (defun asdf (b) (funcall b))

>     (defadvice asdf (before rms (b) activate)
>       (setf b (let ((abc 1) (b b)) (lambda () (print abc) (funcall b)))))

>     (asdf 'ding)

> I think this code should work fine.  It doesn't work with trunk and
> emacs-24, though:

Indeed, it doesn't work.  And because of the way advice.el works
(building a new function by combining the code chunks from all the
pieces of advice applied to that function) it's not easy to fix.

This is partly related to the issue mentioned recently that macro calls
in pieces of advice are expanded late (typically when the advised
function is defined).

BTW, this does not affect the new `advice-add' feature in Emacs trunk.


        Stefan





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-29  4:32 ` Stefan Monnier
@ 2012-11-29 22:50   ` Richard Stallman
  2012-11-30  3:45     ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2012-11-29 22:50 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13023

    Indeed, it doesn't work.  And because of the way advice.el works
    (building a new function by combining the code chunks from all the
    pieces of advice applied to that function) it's not easy to fix.

Would it be possible to fix this by defining a new primitive construct
for use in the constructed function that runs the advince?

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call






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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-29 22:50   ` Richard Stallman
@ 2012-11-30  3:45     ` Stefan Monnier
  2012-11-30 20:11       ` Richard Stallman
  0 siblings, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2012-11-30  3:45 UTC (permalink / raw)
  To: rms; +Cc: 13023

>     Indeed, it doesn't work.  And because of the way advice.el works
>     (building a new function by combining the code chunks from all the
>     pieces of advice applied to that function) it's not easy to fix.
> Would it be possible to fix this by defining a new primitive construct
> for use in the constructed function that runs the advice?

I don't think there's a need to add any new primitive.  If someone wants
to dig into advice.el to try and fix it, it can be fixed there (as
evidenced by advice-add).
I personally would rather tell people to use advice-add instead.


        Stefan





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-30  3:45     ` Stefan Monnier
@ 2012-11-30 20:11       ` Richard Stallman
  2012-12-01  4:23         ` Stefan Monnier
  0 siblings, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2012-11-30 20:11 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13023

    I don't think there's a need to add any new primitive.  If someone wants
    to dig into advice.el to try and fix it, it can be fixed there (as
    evidenced by advice-add).
    I personally would rather tell people to use advice-add instead.

That would, in effect, be an incompatible change in interface.
Why make the change?  Is there something wrong with defadvice?

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call






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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-30 20:11       ` Richard Stallman
@ 2012-12-01  4:23         ` Stefan Monnier
  2012-12-02  0:00           ` Juanma Barranquero
  2012-12-02  4:15           ` Richard Stallman
  0 siblings, 2 replies; 11+ messages in thread
From: Stefan Monnier @ 2012-12-01  4:23 UTC (permalink / raw)
  To: rms; +Cc: 13023

> Is there something wrong with defadvice?

Yes: complexity.  Compare nadvice.el and advice.el.  Even after you
remove the long comment at the beginning, the difference in code size
speaks for itself.


        Stefan





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-12-01  4:23         ` Stefan Monnier
@ 2012-12-02  0:00           ` Juanma Barranquero
  2012-12-02  4:15           ` Richard Stallman
  1 sibling, 0 replies; 11+ messages in thread
From: Juanma Barranquero @ 2012-12-02  0:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13023, Richard Stallman

> Even after you
> remove the long comment at the beginning, the difference in code size
> speaks for itself.

Exactly 1,000 lines longer, after removing comments and blank lines:
1,305 vs 305.

(Bored, moi?)

    Juanma





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-12-01  4:23         ` Stefan Monnier
  2012-12-02  0:00           ` Juanma Barranquero
@ 2012-12-02  4:15           ` Richard Stallman
  2012-12-03  0:01             ` Richard Stallman
  1 sibling, 1 reply; 11+ messages in thread
From: Richard Stallman @ 2012-12-02  4:15 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13023

    Yes: complexity.  Compare nadvice.el and advice.el.

The main difference seems to me that part of the arguments of
advice.el get pushed into the function that you need to pass
to advice-add.  So the complexity of using it is no more.
Also, you lose the ability to modify the argument values before
the advised function's body.

The doc string of advice-add is incomplete, so I cannot tell
what all its args mean or what it can really do.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call






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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-12-02  4:15           ` Richard Stallman
@ 2012-12-03  0:01             ` Richard Stallman
  0 siblings, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2012-12-03  0:01 UTC (permalink / raw)
  To: monnier, 13023; +Cc: rms

Correction:

    Yes: complexity.  Compare nadvice.el and advice.el.

The main difference seems to me that part of the arguments of
advice.el get pushed into the function that you need to pass
to advice-add.  So the complexity of using advice-add is no less.
Also, you lose the ability to modify the argument values before
the advised function's body.

The doc string of advice-add is incomplete, so I cannot tell
what all its args mean or what it can really do.

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call






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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2012-11-28 16:17 bug#13023: 24.3.50; lexical binding does not work within defadvice Christopher Schmidt
  2012-11-29  4:32 ` Stefan Monnier
@ 2016-02-02 18:35 ` Marcin Borkowski
  2016-02-02 19:42   ` Stefan Monnier
  1 sibling, 1 reply; 11+ messages in thread
From: Marcin Borkowski @ 2016-02-02 18:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13023

On 2012-11-28, at 23:32, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

>>     ;; -*- lexical-binding: t -*-
>>     (funcall (let ((rms "works"))
>>                (lambda ()
>>                  (message "lex-bind %s" rms))))
>
>>     (defun asdf (b) (funcall b))
>
>>     (defadvice asdf (before rms (b) activate)
>>       (setf b (let ((abc 1) (b b)) (lambda () (print abc) (funcall b)))))
>
>>     (asdf 'ding)
>
>> I think this code should work fine.  It doesn't work with trunk and
>> emacs-24, though:
>
> Indeed, it doesn't work.  And because of the way advice.el works
> (building a new function by combining the code chunks from all the
> pieces of advice applied to that function) it's not easy to fix.
>
> This is partly related to the issue mentioned recently that macro calls
> in pieces of advice are expanded late (typically when the advised
> function is defined).
>
> BTW, this does not affect the new `advice-add' feature in Emacs trunk.

Hi Stefan,
hi all,

does the above mean that this bug should be closed?  AFAIU, new code
should (at least usually) use advice-add, and while the "old" advice
system is not going to be deleted, it is kind of deprecated.

Best,

-- 
Marcin Borkowski
http://mbork.pl/en





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

* bug#13023: 24.3.50; lexical binding does not work within defadvice
  2016-02-02 18:35 ` Marcin Borkowski
@ 2016-02-02 19:42   ` Stefan Monnier
  0 siblings, 0 replies; 11+ messages in thread
From: Stefan Monnier @ 2016-02-02 19:42 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: 13023

> does the above mean that this bug should be closed?

To the extent that I don't know of anyone who intends to fix this
problem, I guess we could close it as "won't fix".


        Stefan





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

end of thread, other threads:[~2016-02-02 19:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28 16:17 bug#13023: 24.3.50; lexical binding does not work within defadvice Christopher Schmidt
2012-11-29  4:32 ` Stefan Monnier
2012-11-29 22:50   ` Richard Stallman
2012-11-30  3:45     ` Stefan Monnier
2012-11-30 20:11       ` Richard Stallman
2012-12-01  4:23         ` Stefan Monnier
2012-12-02  0:00           ` Juanma Barranquero
2012-12-02  4:15           ` Richard Stallman
2012-12-03  0:01             ` Richard Stallman
2016-02-02 18:35 ` Marcin Borkowski
2016-02-02 19:42   ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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