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

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

Re: obarray


From: Emanuel Berg
Subject: Re: obarray
Date: Tue, 17 Dec 2013 03:11:45 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> 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.

OK.

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

Yes :)

> 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).

Yes, this much I understood, only it was hard to
visualize in practice. So: the macro accept code *as
arguments* (code that isn't evaluated) and transforms
that code? Then I get it. I thought the macro just
produced new code, in what case I can't see how it
could be useful because either no one knows about the
macro so no one will use any symbols it may setup, *or*
the macro knows about itself so any references to what
is setup locally will be correct.

-- 
Emanuel Berg, programmer-for-rent. CV, projects, etc at uXu
underground experts united:  http://user.it.uu.se/~embe8573


reply via email to

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