Symbol pollution non-issue.
- From: Kaz Kylheku <kaz@xxxxxxxxxxx>
- Date: Mon, 6 Feb 2012 21:05:53 +0000 (UTC)
You know I was just thinking about this whole non-issue that seems to irk some
people that if you misspell some symbol in your REPL, it gets interned and then
stays there forever until you manually scrub it away. I know that Clojure
obsesses over this also: it has a way by which such symbols are treated as
What if packages simply used weak pointers for hanging on to symbols? So, come
garbage collection time, if the only reference to a symbol is via its
registration in the package system, it disappears.
If you call (intern "FOO" some-package), ignore the return value, and then the
next time you call (intern "FOO" some-package), you may get a different object.
However, sucha program has no way to tell that it got a different object; it
has no reference to the previously returned symbol to be able to make a
comparison, and if it does retain that reference, then doing so ensures that
the same symbol is returned.
It's a change in behavior for a program which interns a symbol, discards the
reference and then performs a FIND-SYMBOL to check whether the symbol is still
in the package. It may or may not be.
It seems as if DEFPACKAGE breaks because DEFPACKAGE is used to introduce a
bunch of symbols. The weakness could be set up on a per symbol basis. For
instance exported symbols could be normal references, protected from lapsing
Shadowing definitions pose another problem. We sometimes make visible one
package inside another package, but then shadow some selectged symbols.
The shadowing symbols are often internal, and so not protected from lapsing by
the above rule. Solution: the symbols which are in the shadow symbol list of a
package are also protected from lapsing.
The principle is to separate "semantic garbage" symbols in a package,
from ones that are deliberate installed there by programmer intent.
- Prev by Date: Re: lexical package aliases?
- Next by Date: Re: Symbol pollution non-issue.
- Previous by thread: Compile file with specific optimization
- Next by thread: Re: Symbol pollution non-issue.