- "Loads a module when it has not been already. PATHNAME, if supplied,
- is a single pathname or list of pathnames to be loaded if the module
- needs to be. If PATHNAME is not supplied, then a list of files are
- looked for that were registered by a DEFMODULE form. If the module
- has not been defined, then a file will be loaded whose name is formed
- by merging \"modules:\" and MODULE-NAME (downcased if it is a symbol).
- This merged name will be probed with both a .lisp extension and any
- architecture-specific FASL extensions, and LOAD will be called on it
- if it is found."
- ;; KLUDGE: Does this really match the doc string any more? (Did it ever
- ;; match the doc string? Arguably this isn't a high priority question
- ;; since REQUIRE is deprecated anyway and I've not been very motivated
- ;; to maintain CMU CL extensions like DEFMODULE.. -- WHN 19990804
- (setf module-name
- (module-name-string module-name))
- (unless (member module-name *modules* :test #'string=)
- (if pathname
- (unless (listp pathname) (setf pathname (list pathname)))
- (let ((files (module-files module-name)))
- (if files
- (setf pathname files)
- (setf pathname (list (merge-pathnames "modules:" module-name))))))
- (dolist (ele pathname t)
- (load ele))))
+ "Loads a module, unless it already has been loaded. PATHNAMES, if supplied,
+ is a designator for a list of pathnames to be loaded if the module
+ needs to be. If PATHNAMES is not supplied, functions from the list
+ *MODULE-PROVIDER-FUNCTIONS* are called in order with MODULE-NAME
+ as an argument, until one of them returns non-NIL. User code is
+ responsible for calling PROVIDE to indicate a successful load of the
+ module."
+ (let ((name (string module-name)))
+ (when (member name *requiring* :test #'string=)
+ (require-error "~@<Could not ~S ~A: circularity detected. Please check ~
+ your configuration.~:@>" 'require module-name))
+ (let ((saved-modules (copy-list *modules*))
+ (*requiring* (cons name *requiring*)))
+ (unless (member name *modules* :test #'string=)
+ (cond (pathnames
+ (unless (listp pathnames) (setf pathnames (list pathnames)))
+ ;; ambiguity in standard: should we try all pathnames in the
+ ;; list, or should we stop as soon as one of them calls PROVIDE?
+ (dolist (ele pathnames t)
+ (load ele)))
+ (t
+ (unless (some (lambda (p) (funcall p module-name))
+ *module-provider-functions*)
+ (require-error "Don't know how to ~S ~A."
+ 'require module-name)))))
+ (set-difference *modules* saved-modules))))
+