X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fmodule.lisp;h=c9f1861c2c110d97ea50daf5daa392e151695483;hb=cd13034f9415f64cdaa05893a4ac5ff1e95c97bd;hp=77fe18b5b80149cc607d7fa3735f9ae4992d64d6;hpb=edc8da40fb17de047e290ed6bd819e096e435dc9;p=sbcl.git diff --git a/src/code/module.lisp b/src/code/module.lisp index 77fe18b..c9f1861 100644 --- a/src/code/module.lisp +++ b/src/code/module.lisp @@ -22,7 +22,7 @@ "This is a list of module names that have been loaded into Lisp so far. It is used by PROVIDE and REQUIRE.") -(defvar sb!ext::*MODULE-PROVIDER-FUNCTIONS* '(module-provide-contrib) +(defvar *module-provider-functions* '(module-provide-contrib) "See function documentation for REQUIRE") @@ -41,30 +41,45 @@ 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." - (unless (member (string module-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)) - sb!ext::*module-provider-functions*) - (error "Don't know how to load ~A" 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 ((saved-modules (copy-list *modules*))) + (unless (member (string module-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*) + (error "Don't know how to load ~A" module-name))))) + (set-difference *modules* saved-modules))) ;;;; miscellany (defun module-provide-contrib (name) - "Stringify and downcase NAME if it is a symbol, then attempt to load - the file $SBCL_HOME/name/name" - (let ((name (if (symbolp name) (string-downcase (symbol-name name)) name))) - (load - (merge-pathnames (make-pathname :directory (list :relative name) - :name name) - (truename (posix-getenv "SBCL_HOME"))))) - (provide name)) - - + "Stringify and downcase NAME, then attempt to load the file + $SBCL_HOME/name/name" + (let* ((filesys-name (string-downcase (string name))) + (unadorned-path + (merge-pathnames + (make-pathname :directory (list :relative filesys-name) + :name filesys-name) + (truename (posix-getenv "SBCL_HOME")))) + (fasl-path (merge-pathnames + (make-pathname :type *fasl-file-type*) + unadorned-path)) + (lisp-path (merge-pathnames (make-pathname :type "lisp") + unadorned-path))) + ;; KLUDGE: there's a race condition here; the file we probe could + ;; be removed by the time we get round to trying to load it. + ;; Maybe factor out the logic in the LOAD guesser as to which file + ;; was meant, so that we can use it here on open streams instead? + (when (or (probe-file unadorned-path) + (probe-file fasl-path) + (probe-file lisp-path)) + (load unadorned-path) + t)))