Lisp Packages are Domains

In C2:CommonLisp, or any language that uses C2:GenericFunction s instead of class encapsulation, the package actually defines a domain. By domain, I mean a vocabulary in which each word has only one meaning.

Since C2:CommonLisp only allows for a single function signature within each package, this meaning for the word must be well-defined.

Often, the same concepts appear in multiple domains. Sometimes they keep the same names and it’s easy to :use a package in order to extend that domain with your own. However, sometimes the concepts carry over, but the vocabulary doesn’t. Currently that means that for each word in the vocabulary, you need to do this:

sh: /home/pfeilgm/bin/enscript: No such file or directory

Of course, defalias is a popular utility to make this renaming easier, but it\’s not part of the standard. I wonder if this could be made even simpler with an idea stolen from Eiffel: feature renaming:

sh: /home/pfeilgm/bin/enscript: No such file or directory

This makes the domain translation explicit.

Thinking of packages as domains may help limit the naming conflicts that arise in C2:GenericFunction-based OO systems, since people often try to use the packages much like Java packages, rather than like Perlpackages (a much closer, albeit single-dispatch, analogue).

Leave a Reply