help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: elisp: apply variable or function


From: Zhu, Shenli
Subject: Re: elisp: apply variable or function
Date: Sun, 11 Apr 2010 15:05:59 +0800
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.8) Gecko/20100227 Thunderbird/3.0.3

On 04/11/2010 02:23 PM, Ian Eure wrote:
On Apr 10, 2010, at 11:13 PM, "Zhu, Shenli"<address@hidden>  wrote:

Dear all,

I am tracing the code in gud.el(grand unified debugger) and find code snippet 
below hard to understand:

(defvar gud-marker-filter nil)
(put 'gud-marker-filter 'permanent-local t)
... ...
(defun gud-marker-filter (&rest args)
  (apply gud-marker-filter args))

The local permanent variable and function have the same name "gud-marker-filter". But, why elisp engine 
*apply* variable "gud-marker-filter" but not function "gud-marker-filter"(C-h f tell me 
"apply function&rest arguments)?

It will apply the function referenced by the gud-marker-filter
variable. Elisp is a lisp-2, so function and variable symbols are
distinct from each other. This code may help you understand:

(let ((blah 'message))
   (defun blah (&rest args)
     (apply blah args))

   (blah "hi"))

I.e. Blah as a variable is distinct from blah as a function.

I believe that the way this is implemented internally is that blah is
one symbol which has one  cell for the value as a variable and a cell
for the value as a function. But the effect in this case is the same
as if they were separate symbols entirely.

  - Ian
Hi Ian, thank you!

Do you mean
(apply 'blah args) will call the function blah
(apply blah args) will call the function pointer in variable blah?

Regards,
Shenli




reply via email to

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