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

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

Re: obarray


From: Michael Heerdegen
Subject: Re: obarray
Date: Tue, 17 Dec 2013 02:47:17 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Barry Margolin <barmar@alum.mit.edu> writes:

> > Is there a way to confirm this? How can I access a
> > symbol's value, if the symbol isn't in the obarray? If
> > it isn't in the obarray, where is it? Is there a buffer
> > and/or "scope" (i.e. form or process) local/temporary
> > object array or anything of the like?

No.  They are just existing in memory, and will not be garage collected,
as long as they can be referenced from Lisp.  There is also no array of
all existing strings, of all window configurations, etc.  So you can't
tell Lisp to give you a complete list of all currently existing strings,
window configurations, or (uninterned) symbols.  There is just no need
to organize those objects in a user visible structure.

OTOH, an uninterned symbol can be used like any other symbol: it can be
set, used to hold a function, etc.

> You can access it the same way you can access the contents of arrays and 
> lists -- by getting to it from some other variable (or cons cell or 
> array element) that references it. That's what the variable 
> uninterned-symbol is for.
>
> (symbol-value uninterned-symbol) => bar

Of course, this is not very useful, it was just a demonstration, not a
realistic use case.  When using uninterned symbols in macros, you can
"paste" these symbols in the expansion code which will be evaluated at
run-time.  So, programs _can_ contain uninterned symbols; you can really
_use_ uninterned symbols in code.  Not in code read from a file or
buffer, but in code generated by macros.  This way, you avoid that you
accidentally use a symbol that is already "in use" (e.g. in the code the
macro transforms).


Regards,

Michael.




reply via email to

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