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

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

Re: symbols and cells


From: Michael Heerdegen
Subject: Re: symbols and cells
Date: Thu, 15 May 2014 22:16:06 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.90 (gnu/linux)

Christopher Howard <cmhoward2@alaska.edu> writes:

> I'm still working through the earlier parts of the Elisp
> documentation, but I am curious: How does one define the variable cell
> and function cell for an /uninterned/ symbol? The docs indicate you
> can do this:
>
> (defvar sym (make-symbol "foo"))
>
> But how do you add a function or variable value to foo without
> interning it?

"Interning it" is a bit imprecise, since an uninterned symbol can't be
interned, only the string "foo" could be interned, and the result would be
different from any uninterned symbol of the same name.

You can use the functions `set' to set the value cell and `fset' to set
the function cell.

An even better question is: how would you call this uninterned symbol as a
function...?

Using uninterned symbols is almost only useful when macros are involved.
You should not care too much about them until you use macros.

> On a related note, I'm curious about this perverse construction:
>
> (defvar sym1 (lambda (n) (+ 1 n)))
>
> Is it actually possible to call the the lambda somehow?

Of course - with `funcall'.  And it's not perverse at all in Lisp where
functions are first class objects.

That Elisp is Lisp 2 (symbols have separate value and function cells)
doesn't mean that you can't bind a variable to a function (i.e., set the
value cell of a symbol to a function).  On the contrary, this is quite
normal.


Michael.




reply via email to

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