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

Re: COMPILE-FILE-SYMBOL-HANDLING:HOME-PACKAGE



This proposal came out differently than I expected:

"When a compiled file is loaded, the interned symbols it
references are found by calling INTERN at load time with two arguments,
the name of the symbol and the package with the same name as
the compile-time symbol's home package.  ... "

This doesn't ensure that the home package remains the same across
compilation and loading, which I consider the key consideration.
How about this statement instead?

"When a file is compiled, the symbol name is recorded together
with the home package name and an indication of whether the
symbol is external in its home package.  At load time the
symbol is effectively looked up with:

(find-symbol string (find-package pkg-name))

If the symbol is noted as external, it must be found at load
time as :external.  If it is noted as internal, it must either
be present in the package or not found at all.  If it is not found
at all, it is created as if by:

(intern string (find-package pkg-name))

If the package system is not in a suitable state, an error is
signalled."

Here is some code that purports to do the right thing:

(defun resolve-symbol (name pkg-name external?)
  (multiple-value-bind (sym where)
      (find-symbol string (find-package pkg-name))
    (if external?
        (if (eq where :external) sym <signal error>)
      (case where
        ((:internal :external) sym)
        (nil (intern string (find-package pkg-name)))
        (otherwise <signal error>)))))

---------------------------

This is what I consider "the right thing".  I'd like to see it
given as one of the alternative proposals if it isn't already what
was intended by proposal HOME-PACKAGE.

				-Cris