On Wed, 16 Nov 2005, Pascal Costanza wrote:
> I don't completely undertand what you're trying to achieve, but maybe using
> an idiom common in the CLOS MOP could help. You could make require call a
> generic function require-using-system (or some such), and then get more
> fine-grained control over the behavior of require. Here is a sketch.
Almost, but not quite.
I'm trying to ensure that eg. (REQUIRE :SWANK) will get the right Swank no
matter how many copies are lying around the file system, unless the user
has gone out of his way to say that he really wants a different Swank.
So dynamic scoping is not what I'm after.
(setf *system* my-system)
Globally frobbing *SYSTEM* has the same problem as the current approach:
any further modifications to REQUIRE by further specicalization are in
danger of accidentally losing the magic I've hung on it.
In scheme like yours if the module-name was canonized to a keyword by
REQUIRE (something I'm not offhand sure we're allowed to do if it requires
interning) I could use an EQL-specializer on the ones I care about to
ensure correct behaviour, but I'm not sure I see the advantage.
(defun require (name &optional pathnames)
(or (require-from-pathnames name pathnames)
(require-using-class name (find-module-class name)))
(define-module-class important-module ())
(define-module-class swank (important-module))
(defmethod require-using-class (name (module-class important-module))
would work too. If people find this less icky then (SETF MODULE-PROVIDER),
then I'd be happy to implement something like this.
-- Nikodemus Schemer: "Buddha is small, clean, and serious."
Lispnik: "Buddha is big, has hairy armpits, and laughs."