From: Matthew Danish
Subject: Accessibility of symbols
Date: 
Message-ID: <20021011112634.J9853@lain.res.cmu.edu>
CLHS glossary:

``accessible /adj/ - [...]
3. (of a symbol in a package) capable of being referenced without a
package prefix when that package is current, regardless of whether the
symbol is present in that package or is inherited.''

CLHS Chapter 6.1.2.1.7, under ``symbol, symbols'':

``These Loop schemas iterate over symbols that are /accessible/ in a given
package.''

Example:

(defpackage "FOO" (:use "COMMON-LISP") (:shadow "ATOM"))
(intern "ATOM" "FOO")
(in-package "FOO")
(loop for x being each symbol in *package*
      when (string-equal x "ATOM")
        collect x)

The results of the LOOP:
CMUCL (18d): (ATOM)
SBCL (0.7.3): (ATOM)
Allegro CL (6.2): (COMMON-LISP:ATOM ATOM)
LispWorks (4.2.0): (COMMON-LISP:ATOM ATOM)
CLISP (2.30): (ATOM)

Given that the current package is "FOO" and accessibility is defined to
mean "does not need a package prefix to reference it", it seems to me
that COMMON-LISP:ATOM is not accessible in package "FOO" and should not
be returned by the above LOOP.

The code that led up to this was an attempt to shadow some
arithmetic-related symbols in the COMMON-LISP package and re-export them
along with the rest of COMMON-LISP from the INFINITE-COMMON-LISP package
(which, as you might guess, redefines some operators to handle the idea
of positive and negative infinity).

-- 
; Matthew Danish <·······@andrew.cmu.edu>
; OpenPGP public key: C24B6010 on keyring.debian.org
; Signed or encrypted mail welcome.
; "There is no dark side of the moon really; matter of fact, it's all dark."
From: Erik Naggum
Subject: Re: Accessibility of symbols
Date: 
Message-ID: <3243373805862280@naggum.no>
* Matthew Danish
| Given that the current package is "FOO" and accessibility is defined to
| mean "does not need a package prefix to reference it", it seems to me
| that COMMON-LISP:ATOM is not accessible in package "FOO" and should not
| be returned by the above LOOP.

  I see absolutely nothing wrong with your reasoning here.  I am somewhat
  unhappy that the following code behaves correctly in Allegro CL 6.2:

(do-symbols (symbol)
  (when (string-equal symbol "ATOM")
    (print symbol)))

  because it does an explicit test for membership in the shadowed-symbols
  list in a package (see the expansion of the macro).

  The `loop� form uses `with-package-iterator�, so the following form also
  exhibits the problem:

(with-package-iterator (get-symbol :foo :inherited)
  (loop
    (multiple-value-bind (flag symbol access package) (get-symbol)
      (when (string-equal symbol "atom")
        (print (list symbol access package)))
      (unless flag
        (return)))))

  Allegro CL 6.2 violates the standard when it does not obey the requirement
  that `:inherited� returns symbols that are shadowed.  The requirement is
  that the symbols returned are specifically:

  The symbols that are exported by used packages and that are not shadowed.

  So Allegro CL and LispWorks contain a pretty serious bug in that they do
  not exclude shadowed symbols the way `do-symbols� does.  It is pretty sad
  that the two forms use such radically different underlying mechanisms.

-- 
Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.