unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* labels usage
@ 2012-06-12  6:53 Katsumi Yamaoka
  2012-06-12  7:25 ` Andreas Schwab
  2012-06-12 13:07 ` Stefan Monnier
  0 siblings, 2 replies; 4+ messages in thread
From: Katsumi Yamaoka @ 2012-06-12  6:53 UTC (permalink / raw)
  To: emacs-devel; +Cc: emacs-w3m

Hi,

Is this a wrong usage?

(let (fn)
  (labels ((fx (arg) arg))
    (setq fn 'fx))
  (funcall fn 99))

It worked until cl changed.  Now this labels form is expanded into:

(progn
  (defvar --cl---cl-fx----)
  (let ((--cl---cl-fx---- nil))
    (progn (set '--cl---cl-fx---- #'(lambda (arg) arg))
	   (setq fn 'fx))))

Whereas it was:

(let ((--cl---cl-var--86211-- nil))
  (progn (set '--cl---cl-var--86211-- #'(lambda (arg) arg))
	 (setq fn (symbol-value '--cl---cl-var--86211--))))

Did we get to have no way to access the function definition, that
a labels form generates, in the outside of the labels form?
(If so, we have a solution; we have to simply replace labels with
 let in such a Lisp code, i.e., emacs-w3m.)



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

* Re: labels usage
  2012-06-12  6:53 labels usage Katsumi Yamaoka
@ 2012-06-12  7:25 ` Andreas Schwab
  2012-06-12  7:48   ` Katsumi Yamaoka
  2012-06-12 13:07 ` Stefan Monnier
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2012-06-12  7:25 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: emacs-w3m, emacs-devel

Katsumi Yamaoka <yamaoka@jpl.org> writes:

> Hi,
>
> Is this a wrong usage?
>
> (let (fn)
>   (labels ((fx (arg) arg))
>     (setq fn 'fx))
>   (funcall fn 99))

You should use #'fx instead.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



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

* Re: labels usage
  2012-06-12  7:25 ` Andreas Schwab
@ 2012-06-12  7:48   ` Katsumi Yamaoka
  0 siblings, 0 replies; 4+ messages in thread
From: Katsumi Yamaoka @ 2012-06-12  7:48 UTC (permalink / raw)
  To: schwab; +Cc: emacs-w3m, emacs-devel

In [emacs-w3m : No.11847] Andreas Schwab wrote:
> Katsumi Yamaoka <yamaoka@jpl.org> writes:
>> Is this a wrong usage?
>>
>> (let (fn)
>>   (labels ((fx (arg) arg))
>>     (setq fn 'fx))
>>   (funcall fn 99))

> You should use #'fx instead.

Ok, we *should* use #' from now on.  This was what Michael Heerdegen
wrote in the emacs-w3m list a while ago.  Maybe it didn't go well
when I tried it was I forgot to build emacs-w3m from scratch.  I'll
try it again.  Thanks.



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

* Re: labels usage
  2012-06-12  6:53 labels usage Katsumi Yamaoka
  2012-06-12  7:25 ` Andreas Schwab
@ 2012-06-12 13:07 ` Stefan Monnier
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Monnier @ 2012-06-12 13:07 UTC (permalink / raw)
  To: Katsumi Yamaoka; +Cc: emacs-w3m, emacs-devel

>   (labels ((fx (arg) arg))
>     (setq fn 'fx))

'fx evaluates to the *symbol* `fx', not the *function* `fx'.  In Elisp
until Emacs-24, you can use pretty much interchangeably a function and
the symbol to which it is bound, but with lexical scoping this is not
true any more.  CL's `labels' used to follow the "Elisp tradition" and
looked inside `quote' to turn that symbol into a reference to the
locally defined function.  But that was fundamentally a bug.


        Stefan



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

end of thread, other threads:[~2012-06-12 13:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-12  6:53 labels usage Katsumi Yamaoka
2012-06-12  7:25 ` Andreas Schwab
2012-06-12  7:48   ` Katsumi Yamaoka
2012-06-12 13:07 ` 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).