all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>,
	Nic Ferrier <nferrier@ferrier.me.uk>
Cc: emacs-devel@gnu.org
Subject: RE: adding namespaces to emacs-lisp (better elisp?)
Date: Fri, 26 Jul 2013 15:00:03 -0700 (PDT)	[thread overview]
Message-ID: <3b4713cb-5fd5-498b-b9ee-a676f0fef845@default> (raw)
In-Reply-To: <jwv38r1jbhm.fsf-monnier+emacs@gnu.org>

> > I am not wedded to the proposal of using the global obarray first. The
> > rules for interning are slightly more complicated in that case:
> > - given a string X
> > - lookup X in the local obarray
> > - if it exists return the symbol
> > - else
> > -  lookup X in the global obarray
> > -  if it exists return the symbol
> > -  else
> > -    add the symbol to the local obarray
> 
> Exactly.  In Mathematica, they have a list of obarrays to check in
> sequence and a "current" obarray to which things are added if the
> lookup fails.  Sounds clean and simple to me.

And in Common Lisp (from CLTL, 1984 - didn't check CLTL2):

"When the Lisp reader has, by parsing, obtained a string of characters
 thought to name a symbol, that name is looked up in the current package.
 This lookup may involve looking in other packages whose external symbols
 are inherited by the current package.  If the name is found, the
 corresponding symbol is returned.  If the name is not found (that is,
 there is no symbol of that name accessible in the current package), a
 new symbol is created for it and is placed in the current package as an
 internal symbol.  Moreover, the current package becomes the owner (home
 package) of the symbol, and so the symbol becomes interned in the current
 package.  If the name is later read again while this same package is
 current, the same symbol will then be found and returned."

> > My feeling is that an import should be like the creation of an alias.
> 
> Function alias?  Variable alias?
> I don't much like the sounds of it.  I'd much rather make sure they are
> simply one and the same symbol (I guess "symbol alias").

Yes.

In CL there are two different things, BTW:

* `import': Importing a symbol into a package.  Importing makes the
symbol *present*, not just *accessible* in the importing package.  If a different symbol with the same name is already accessible in the
importing package then a user-correctable error is raised: `import'
avoids letting one symbol shadow another.

* `use-package': Inheriting a symbol, by using another package in which
it is external.  The symbol becomes *accessible* as an internal symbol
in the using package.  (There is no way to inherit the internal symbols
of a package.)

`use-package', unlike `import', does not cause any new symbols to be
present in the using package.  It just makes them accessible by
inheritance.

A symbol is *accessible* in a package if it can be referred to without
a package qualifier when that package is current.  A symbol is *present*
in a package if the name-to-symbol mapping (obarray entry) is in the
package itself and is not inherited.  A symbol is interned in a given
package if (a) it is accessible there and (b) it is owned by some package
(i.e., it is interned somewhere). 

`intern' causes a symbol to be interned in a package, like this:

"[I]t first looks for the symbol among the external and internal symbols
 of the package itself [i.e., present there]; then it looks through the
 external symbols of the used packages in some unspecified order.  The
 order does not matter; according to the rules for handling name conflicts
 ..., if conflicting symbols appear in two or more packages inherited by
 package X, a symbol of this name must also appear [i.e., be present] in
 X itself as a shadowing symbol." 

"If the symbol was previously unowned, then the package it is interned
 in becomes its owner (home package); but if the symbol was previously
 owned by another package, that other package continues to own the
 symbol."

FWIW, perhaps the most important part of the CL packages design are
these consistency rules:

"
* Read-read consistency: Reading the same print name always results in
  the same (`eq') symbol.

* Print-read consistency: An interned symbol always prints as a sequence
  of characters that, when read back in, yields the same (`eq') symbol.

* Print-print consistency: If two interned symbols are not `eq', then
  their printed representations will be different sequences of characters.
"



  parent reply	other threads:[~2013-07-26 22:00 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-26 14:08 adding namespaces to emacs-lisp (better elisp?) Nic Ferrier
2013-07-26 14:34 ` Drew Adams
2013-07-26 17:01   ` Pascal J. Bourguignon
2013-07-26 17:01   ` CommonLisp namespace system (was Re: adding namespaces to emacs-lisp (better elisp?)) Nic Ferrier
2013-07-26 17:19     ` Drew Adams
2013-07-26 18:26       ` Sebastian Wiesner
2013-07-26 18:53         ` Drew Adams
2013-07-26 21:08         ` Pascal J. Bourguignon
2013-07-26 18:23     ` Stefan Monnier
2013-07-26 18:32       ` Nic Ferrier
2013-07-26 18:45     ` Tom Tromey
2013-07-26 18:58       ` Drew Adams
2013-07-26 19:06         ` Nic Ferrier
2013-07-26 20:46           ` CommonLisp namespace system Lars Brinkhoff
2013-07-26 20:57             ` Drew Adams
2013-07-26 21:47               ` Nic Ferrier
2013-07-29 17:31                 ` Lars Brinkhoff
2013-07-26 20:57           ` CommonLisp namespace system (was Re: adding namespaces to emacs-lisp (better elisp?)) Drew Adams
2013-07-27  7:17           ` Richard Stallman
2013-07-27  8:13             ` Nic Ferrier
2013-07-27 11:43               ` Bastien
2013-07-27 12:00                 ` David Engster
2013-07-27 16:56                   ` Nic Ferrier
2013-07-27 23:52               ` Richard Stallman
2013-07-28  7:22                 ` Nic Ferrier
2013-07-28  8:18                   ` Jambunathan K
2013-07-28 12:10                   ` Richard Stallman
2013-07-28 13:48                     ` Nic Ferrier
2013-07-29 10:12                       ` Richard Stallman
2013-07-29 10:45                         ` Nic Ferrier
2013-07-30  0:31                           ` Richard Stallman
2013-07-27  9:37             ` CommonLisp namespace system Lars Brinkhoff
2013-07-26 19:42         ` CommonLisp namespace system (was Re: adding namespaces to emacs-lisp (better elisp?)) Drew Adams
2013-07-26 21:26       ` Juanma Barranquero
2013-07-26 21:06     ` Pascal J. Bourguignon
2013-07-26 21:44       ` Nic Ferrier
2013-07-27  7:16   ` adding namespaces to emacs-lisp (better elisp?) Richard Stallman
2013-07-26 15:43 ` Stefan Monnier
2013-07-26 16:56   ` Nic Ferrier
2013-07-26 18:18     ` Stefan Monnier
2013-07-26 19:00       ` Nic Ferrier
2013-07-26 20:59         ` Stefan Monnier
2013-07-26 21:43           ` Nic Ferrier
2013-07-26 21:59             ` Drew Adams
2013-07-26 22:21             ` Stefan Monnier
2013-07-26 22:33               ` Nic Ferrier
2013-07-27  0:51                 ` Stefan Monnier
2013-07-27  8:27                   ` Nic Ferrier
2013-07-27 14:12                     ` Stefan Monnier
2013-07-27 16:17                       ` Nic Ferrier
2013-07-27 17:28                         ` Stefan Monnier
2013-07-27 10:35                   ` Pascal J. Bourguignon
2013-07-26 22:00           ` Drew Adams [this message]
2013-07-27  0:49             ` Stefan Monnier
2013-07-27  1:13               ` Drew Adams
2013-07-27  7:02               ` Lars Brinkhoff
2013-07-27 10:33                 ` Pascal J. Bourguignon
2013-07-31  6:48                   ` Lars Brinkhoff
2013-07-27 10:31               ` Pascal J. Bourguignon
2013-07-27 14:14                 ` Stefan Monnier
2013-07-27 16:43                   ` Drew Adams
2013-07-26 17:21   ` Davis Herring

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

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

  git send-email \
    --in-reply-to=3b4713cb-5fd5-498b-b9ee-a676f0fef845@default \
    --to=drew.adams@oracle.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=nferrier@ferrier.me.uk \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.