[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: obarray
From: |
Barry Margolin |
Subject: |
Re: obarray |
Date: |
Sat, 14 Dec 2013 23:17:37 -0500 |
User-agent: |
MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) |
In article <87bo0irj13.fsf@nl106-137-194.student.uu.se>,
Emanuel Berg <embe8573@student.uu.se> wrote:
> Juanma Barranquero <lekktu@gmail.com> writes:
>
> > I think it's pretty clear: is a symbol table for
> > (most) symbols. It is implemented as a vector, of
> > prime length because of the way the hashing is done,
> > and it does not make sense to examine it from Lisp
> > *as a vector*, because its elements are not symbols,
> > but have a more complex structure (basically, they
> > implemented some kind of hash table). So the way to
> > process all elements of that symbol table is to use
> > mapatoms; looping over the vector won't give the
> > symbols stored in the table.
>
> Well, that description was a lot better.
>
> So it is a hash table of symbols: variables, constants,
> :keywords, functions, ...?
>
> And when you do `defvar', is the symbol name inserted
> into this data structure based on some property -
> perhaps the name itself, or type (if a "symbol" isn't
> atomic)?
Symbols are inserted into the obarray when they're interned. Either by
calling the intern function explicitly, or implicitly when the symbol is
seen by the Lisp reader.
This is how Lisp ensures that every time you type a symbol, it refers to
the same one: the first time you type it, it gets added to the obarray,
and function times find the symbol in the obarray and don't create a new
symbol.
> Is the value inserted as well or do they use some sort
> of pointer scheme?
Values are unrelated to whether a symbol is in the obarray. An
uninterned symbol can have a value.
(setq uninterned-symbol (make-symbol "foo"))
(setf (symbol-value uninterned-symbol) 'bar)
This symbol "foo" won't be in the obarray, but it still has a value.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
- obarray, Emanuel Berg, 2013/12/14
- Re: obarray, Juanma Barranquero, 2013/12/14
- Message not available
- Re: obarray, Emanuel Berg, 2013/12/14
- Re: obarray,
Barry Margolin <=
- Re: obarray, Michael Heerdegen, 2013/12/14
- Re: obarray, Emanuel Berg, 2013/12/15
- Re: obarray, Barry Margolin, 2013/12/15
- Re: obarray, Emanuel Berg, 2013/12/15
- Re: obarray, Barry Margolin, 2013/12/16
- Re: obarray, Michael Heerdegen, 2013/12/16
- Message not available
- Re: obarray, Emanuel Berg, 2013/12/16
- Re: obarray, Michael Heerdegen, 2013/12/16
- Message not available
- Re: obarray, Emanuel Berg, 2013/12/16
- Re: obarray, Barry Margolin, 2013/12/17