unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* LISP symbols defined with DEFUN
@ 2007-04-13 12:14 A Soare
  0 siblings, 0 replies; 3+ messages in thread
From: A Soare @ 2007-04-13 12:14 UTC (permalink / raw)
  To: Emacs   Help  [help-gnu-emacs]

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

Thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LISP symbols defined with DEFUN
@ 2007-04-13 14:36 A Soare
  0 siblings, 0 replies; 3+ messages in thread
From: A Soare @ 2007-04-13 14:36 UTC (permalink / raw)
  To: Emacs   Help  [help-gnu-emacs]

I saw using the preprocessor.

defsubr interns them using 
struct Lisp_Subr __attribute__ ((__aligned__ (1 << GCTYPEBITS)))

etcetera.

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LISP symbols defined with DEFUN
       [not found] <mailman.2034.1176466728.7795.help-gnu-emacs@gnu.org>
@ 2007-04-13 16:48 ` Pascal Bourguignon
  0 siblings, 0 replies; 3+ messages in thread
From: Pascal Bourguignon @ 2007-04-13 16:48 UTC (permalink / raw)
  To: help-gnu-emacs

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-13 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-13 12:14 LISP symbols defined with DEFUN A Soare
  -- strict thread matches above, loose matches on Subject: below --
2007-04-13 14:36 A Soare
     [not found] <mailman.2034.1176466728.7795.help-gnu-emacs@gnu.org>
2007-04-13 16:48 ` Pascal Bourguignon

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