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: Ian Eure
Subject: Re: elisp: apply variable or function
Date: Sat, 10 Apr 2010 23:23:49 -0700

On Apr 10, 2010, at 11:13 PM, "Zhu, Shenli" <zhushenli2@gmail.com> 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




reply via email to

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