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