unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: obarray
Date: Sat, 14 Dec 2013 23:17:37 -0500	[thread overview]
Message-ID: <barmar-DC4996.23173714122013@news.eternal-september.org> (raw)
In-Reply-To: 87bo0irj13.fsf@nl106-137-194.student.uu.se

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


  parent reply	other threads:[~2013-12-15  4:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-15  0:54 obarray Emanuel Berg
2013-12-15  1:14 ` obarray Juanma Barranquero
     [not found] ` <mailman.9268.1387070101.10748.help-gnu-emacs@gnu.org>
2013-12-15  1:37   ` obarray Emanuel Berg
2013-12-15  1:56     ` obarray Michael Heerdegen
2013-12-15  1:59     ` obarray Juanma Barranquero
     [not found]     ` <mailman.9271.1387072648.10748.help-gnu-emacs@gnu.org>
2013-12-15  4:17       ` obarray Emanuel Berg
2013-12-15  4:17     ` Barry Margolin [this message]
2013-12-15  4:47       ` obarray Michael Heerdegen
2013-12-15  4:55       ` obarray Emanuel Berg
2013-12-15  6:04         ` obarray Barry Margolin
2013-12-15 17:43           ` obarray Emanuel Berg
2013-12-16 17:44             ` obarray Barry Margolin
2013-12-17  1:47               ` obarray Michael Heerdegen
     [not found]               ` <mailman.9442.1387244871.10748.help-gnu-emacs@gnu.org>
2013-12-17  2:11                 ` obarray Emanuel Berg
2013-12-17  2:55                   ` obarray Michael Heerdegen
     [not found]                   ` <mailman.9452.1387248989.10748.help-gnu-emacs@gnu.org>
2013-12-17  3:01                     ` obarray Emanuel Berg
2013-12-17 17:32                       ` obarray Barry Margolin
2013-12-17 17:42                         ` obarray Emanuel Berg
     [not found]       ` <mailman.9279.1387082898.10748.help-gnu-emacs@gnu.org>
2013-12-15  5:11         ` obarray Emanuel Berg
2013-12-15  5:36           ` obarray Emanuel Berg
2013-12-15  6:17             ` obarray Michael Heerdegen
     [not found]             ` <mailman.9283.1387088419.10748.help-gnu-emacs@gnu.org>
2013-12-15 17:51               ` obarray Emanuel Berg
2013-12-15  6:15           ` obarray Michael Heerdegen
     [not found]           ` <mailman.9282.1387088166.10748.help-gnu-emacs@gnu.org>
2013-12-15 17:47             ` obarray Emanuel Berg
2013-12-15  5:58         ` obarray Barry Margolin
2013-12-15 17:28           ` obarray Emanuel Berg
2013-12-17 14:38 ` obarray jack-mac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=barmar-DC4996.23173714122013@news.eternal-september.org \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).