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

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

Re: LISP symbols defined with DEFUN


From: Pascal Bourguignon
Subject: Re: LISP symbols defined with DEFUN
Date: Fri, 13 Apr 2007 18:48:33 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.94 (gnu/linux)

A Soare <alinsoar@voila.fr> writes:

> How/Where LISP symbols defined with DEFUN are inserted in obarray?

Symbols are not inserted in the obarray by defun.  In lisp, symbols
are put in the symbol table when they are read, not when they are
"defined" by the compiler.  When the compiler gets the symbols they
have been inside the symbol table since a long time.

The lisp reader puts the symbol it reads in the obarray (the symbol
table), using the function intern.

It looks like this (pseudo-code):

(defun read (&optional stream)
  (let ((token (read-a-token stream))) ; token is basically a sequence of 
characters.
     (cond
       ((looks-like-an-integer token)
          (parse-integer token))
       ((looks-like-a-string-literal token)
          (parse-string token))
       ((string= "(" token)
          (loop for token = (peek-a-token stream)
                until (string= ")" token) 
                ;; more stuff to handle dotted lists.
                collect (read stream)))
      ((looks-like-a-symbol token)
          (intern token))
      (t
          (error "This token looks like nothing: %S" token)))))

-- 
__Pascal Bourguignon__
http://www.informatimago.com
http://pjb.ogamita.org


reply via email to

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