Re: asdf documentation/*central-registry* bugreport
Hannu Koivisto <[email protected]>
| Newsgroups | gmane.lisp.cclan.general |
|---|---|
| Organization | NOYB |
| Message-ID | <[email protected]> |
Daniel Barlow <[email protected]> writes: > Hannu Koivisto <[email protected]> writes: ... >> FWIW, I think that the usage of functions in *CENTRAL-REGISTRY* >> is somewhat suboptimal. The current method of returning a ... > Yeah, I'd tend to agree, and am considering deprecating it altogether > in favour of something that saw some element of thought in its design. > Maybe along the lines of a list of functions that are called in order > and are responsible for loading or otherwise generating the system > definition, with the default contents of the list being the single > function that does "look through *central-registry* and load the first > systemname.asd we find" I don't know about that element of thought part but how about something like the attached patch? I retained the possibility to have functions in *CENTRAL-REGISTRY*, but they cannot be used for this... > You mean "I have taken care of loading or otherwise generating the > system definition for you, please don't load anything at all"? I > can ...like you suggest here... > see the need for the feature; I don't think *central-registry* is the > place for it (see my previous paragraph) ...but just to return the system file name (or NIL if they can't find the system file). Even though this may not be as clean as possible, I think it is more convenient than relying completely on the following feature. I also introduced *SYSTEM-FINDERS*, which is that list of functions [whose only default item is a function that that does "look through *central-registry* and load the first systemname.asd we find"] that you describe above, and modified FIND-SYSTEM to use it. I asked you about the documentation in IRC but either you /ignore me or didn't want to discuss asdf there or something, so I'm not including any documentation updates concerning this change at the moment. I mainly wanted to know whether you are planning to systain the README as the main "documentation" or maybe move most of the stuff (perhaps everything except for the first two sections) out of it to a LaTeX/DocBook/something document... -- Hannu
asdf-central-registry-enhancement.diff
(text/x-patch, 3.6 KB)
Index: asdf.lisp
===================================================================
RCS file: /cvsroot/cclan/asdf/asdf.lisp,v
retrieving revision 1.51
diff -U3 -r1.51 asdf.lisp
--- asdf.lisp 12 Nov 2002 12:53:27 -0000 1.51
+++ asdf.lisp 15 Nov 2002 16:53:38 -0000
@@ -72,6 +72,7 @@
;#:*component-parent-pathname*
#:*central-registry* ; variables
+ #:*system-finders*
#:operation-error #:compile-failed #:compile-warned #:compile-error
#:system-definition-error
@@ -308,40 +309,53 @@
"/home/dan/src/sourceforge/cclan/asdf/systems/"
#+nil "telent:asdf;systems;"))
-(defun system-definition-pathname (system)
- (let ((name (coerce-name system)))
- (dolist (dir *central-registry*)
- (let* ((defaults (if (and (symbolp dir)
- (fboundp dir))
- (funcall dir name)
- (eval dir)))
- (file (and defaults
- (make-pathname
- :name name :case :local :type "asd"
- :defaults defaults
- :version :newest))))
- (if (and file (probe-file file))
- (return-from system-definition-pathname file))))
- nil))
-
-
-(defun find-system (name &optional (error-p t))
- (let* ((name (coerce-name name))
- (in-memory (gethash name *defined-systems*))
- (on-disk (system-definition-pathname name)))
+(defmethod try-central-registry-entry ((symbol symbol) system)
+ (if (fboundp symbol)
+ (try-central-registry-entry (fdefinition symbol) system)
+ (try-central-registry-entry (symbol-value symbol) system)))
+
+(defmethod try-central-registry-entry ((form list) system)
+ (try-central-registry-entry (eval form) system))
+
+(defmethod try-central-registry-entry ((directory string) system)
+ (try-central-registry-entry (parse-namestring directory) system))
+
+(defmethod try-central-registry-entry ((directory pathname) system)
+ (probe-file (make-pathname :name system :type "asd" :version :newest
+ :case :local :defaults directory)))
+
+(defmethod try-central-registry-entry ((function function) system)
+ (funcall function system))
+
+(defun central-registry-finder (system)
+ (let* ((name (coerce-name system))
+ (in-memory (gethash name *defined-systems*))
+ (on-disk (some (lambda (entry)
+ (try-central-registry-entry entry name))
+ *central-registry*)))
(when (and on-disk
- (or (not in-memory)
- (< (car in-memory) (file-write-date on-disk))))
+ (or (not in-memory)
+ (< (car in-memory) (file-write-date on-disk))))
(let ((*package* (make-package (gensym (package-name #.*package*))
- :use '(:cl :asdf))))
- (format t ";;; Loading system definition from ~A into ~A~%"
+ :use '(:cl :asdf))))
+ (format t ";;; Loading system definition from ~A into ~A~%"
on-disk *package*)
(load on-disk)))
(let ((in-memory (gethash name *defined-systems*)))
- (if in-memory
- (progn (if on-disk (setf (car in-memory) (file-write-date on-disk)))
- (cdr in-memory))
- (if error-p (error 'missing-component :requires name))))))
+ (when in-memory
+ (when on-disk
+ (setf (car in-memory) (file-write-date on-disk)))
+ (cdr in-memory)))))
+
+(defvar *system-finders*
+ '(central-registry-finder))
+
+(defun find-system (name &optional (error-p t))
+ (or (some (lambda (entry)
+ (funcall entry name))
+ *system-finders*)
+ (when error-p
+ (error 'missing-component :requires name))))
(defun register-system (name system)
(format t "Registering ~A as ~A ~%" system name)