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

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

Re: symbols and cells


From: Pascal J. Bourguignon
Subject: Re: symbols and cells
Date: Thu, 15 May 2014 20:07:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (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?

(require 'cl)
(setf (symbol-value sym) 42
      (symbol-function sym) (lambda () 33))

(eval sym) --> 42
(eval (list sym)) --> 33


> 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?

(funcall sym1 (symbol-value sym)) --> 43


-- 
__Pascal Bourguignon__
http://www.informatimago.com/
"Le mercure monte ?  C'est le moment d'acheter !"


reply via email to

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