I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
-T.
Hi Tobias,
I think this would be a good thing.
On Jul 7, 2009, at 6:31 AM, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
-T.
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
How about this:
(defun directory-pathname-p (pathname) (and (member (pathname-name pathname) (list nil :unspecified)) (member (pathname-type pathname) (list nil :unspecified))))
(defun sysdef-central-registry-search (system) (let ((name (coerce-name system)) (to-remove nil)) (block nil (unwind-protect (dolist (dir *central-registry*) (let ((defaults (eval dir))) (cond ((directory-pathname-p defaults) (let ((file (and defaults (make-pathname :defaults defaults :version :newest :name name :type "asd" :case :local)))) (if (and file (probe-file file)) (return file)))) (t (warn "~@<While searching for system `~s`: `~s` evaluated to `~s` which is not a directory. Removing entry from *central- registry*~@:>" system dir defaults) (push dir to-remove))))) ;; cleanup (dolist (dir to-remove) (setf *central-registry* (remove dir *central-registry*)))))))
On Jul 7, 2009, at 7:16 AM, Gary King wrote:
Hi Tobias,
I think this would be a good thing.
On Jul 7, 2009, at 6:31 AM, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
-T.
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
Gary King wrote:
How about this:
(defun directory-pathname-p (pathname) (and (member (pathname-name pathname) (list nil :unspecified)) (member (pathname-type pathname) (list nil :unspecified))))
(defun sysdef-central-registry-search (system) (let ((name (coerce-name system)) (to-remove nil)) (block nil (unwind-protect (dolist (dir *central-registry*) (let ((defaults (eval dir))) (cond ((directory-pathname-p defaults) (let ((file (and defaults (make-pathname :defaults defaults :version :newest :name name :type "asd" :case :local)))) (if (and file (probe-file file)) (return file)))) (t (warn "~@<While searching for system `~s`: `~s` evaluated to `~s` which is not a directory. Removing entry from *central- registry*~@:>" system dir defaults) (push dir to-remove))))) ;; cleanup (dolist (dir to-remove) (setf *central-registry* (remove dir *central-registry*)))))))
This looks great. Minor suggestion: change the "warn" to "cerror". When loading a big system, or a big init file, CL implementations will often spew a lot of messages that will bury a warning. That means that this warning might slip by un-noticed and then you'd get a confusing error later on. CERROR will be more obtrusive and, in this case, I think more obtrusive is right.
On Jul 7, 2009, at 7:16 AM, Gary King wrote:
Hi Tobias,
I think this would be a good thing.
On Jul 7, 2009, at 6:31 AM, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
-T.
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
"Tobias C. Rittweiler" writes:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Wouldn't it be more user-friendly to coerce such pathnames to ones that denote directory names?
-- Richard
Richard M Kreuter writes:
"Tobias C. Rittweiler" writes:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Wouldn't it be more user-friendly to coerce such pathnames to ones that denote directory names?
Yes, I think so. When I wrote my original posting, I was not sure whether such a suggestion would be dismissed as unwished DWIM behaviour, so I chose the more conservative suggestion.
I am not familiar with the intrinsics of the pathname system, so a silly question about a possibly problematic case:
Let's say "/foo/bar" were a symlink pointing to a directory. Would coercing that namestring to denote a directory correctly resolve the symlink?
-T.
Richard M Kreuter writes:
Wouldn't it be more user-friendly to coerce such pathnames to ones that denote directory names?
Small addendum to my previous mail:
Even in the case of automatic coercing, I think ASDF should signal a style-warning for educational purposes.
-T.
New (more complicate) code:
(defun directory-pathname-p (pathname) (and (member (pathname-name pathname) (list nil :unspecific)) (member (pathname-type pathname) (list nil :unspecific))))
(defun pathname-name+type (pathname) "Returns a new pathname consisting of only the name and type from a non-wild pathname." (make-pathname :name (pathname-name pathname) :type (pathname-type pathname)))
(defun ensure-directory-pathname (pathname) (if (directory-pathname-p pathname) pathname (make-pathname :directory `(,@(pathname-directory pathname) ,(namestring (pathname-name+type pathname))))))
(defun sysdef-central-registry-search (system) (let ((name (coerce-name system)) (to-remove nil) (to-replace nil)) (block nil (unwind-protect (dolist (dir *central-registry*) (let ((defaults (eval dir))) (cond ((directory-pathname-p defaults) (let ((file (and defaults (make-pathname :defaults defaults :version :newest :name name :type "asd" :case :local)))) (if (and file (probe-file file)) (return file)))) (t (restart-case (let ((*print-circle* nil)) (error "~@<While searching for system `~a`: `~a` evaluated to `~a` which is not a directory.~@:>" system dir defaults)) (remove-entry-from-registry () :report "Remove entry from *central-registry* and continue" (push dir to-remove)) (coerce-entry-to-directory () :report (lambda (s) (format s "Coerce entry to ~a, replace ~a and continue." (ensure-directory-pathname defaults) dir)) (push (cons dir (ensure-directory-pathname defaults)) to- replace))))))) ;; cleanup (dolist (dir to-remove) (setf *central-registry* (remove dir *central-registry*))) (dolist (pair to-replace) (let* ((current (car pair)) (new (cdr pair)) (position (position current *central-registry*))) (setf *central-registry* (append (subseq *central-registry* 0 position) (list new) (subseq *central-registry* (1+ position))))))))))
On Jul 9, 2009, at 4:04 PM, Tobias C. Rittweiler wrote:
Richard M Kreuter writes:
Wouldn't it be more user-friendly to coerce such pathnames to ones that denote directory names?
Small addendum to my previous mail:
Even in the case of automatic coercing, I think ASDF should signal a style-warning for educational purposes.
-T.
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
Gary King writes:
(defun pathname-name+type (pathname) "Returns a new pathname consisting of only the name and type from a non-wild pathname." (make-pathname :name (pathname-name pathname) :type (pathname-type pathname)))
I believe that FILE-NAMESTRING is supposed to do roughly what you want here.
(defun ensure-directory-pathname (pathname) (if (directory-pathname-p pathname) pathname (make-pathname :directory `(,@(pathname-directory pathname) ,(namestring (pathname-name+type pathname))))))
This loses the device component from PATHNAME, and is otherwise prone to fail in case the host component of *DEFAULT-PATHNAME-DEFAULTS* differs from the host component of PATHNAME. How about
(make-pathname :defaults pathname :directory (append (pathname-directory pathname) (list (file-namestring pathname))) :name nil :type nil :version nil)
?
Regards, Richard
I believe that FILE-NAMESTRING is supposed to do roughly what you want here.
excellent!
(defun ensure-directory-pathname (pathname) (if (directory-pathname-p pathname) pathname (make-pathname :directory `(,@(pathname-directory pathname) ,(namestring (pathname-name+type pathname))))))
This loses the device component from PATHNAME, and is otherwise prone to fail in case the host component of *DEFAULT-PATHNAME-DEFAULTS* differs from the host component of PATHNAME. How about
absolutely. -- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Wouldn't it be more user-friendly to coerce such pathnames to ones that denote directory names?
It sounds like there are two questions:
* How to inform the user that something is wrong
* How to continue in the presence of the wrongosity
I agree with Robert that a cerror is better than a warning because system loading already emits so much verbiage that a warning is likely to be lost in the haze.
Today I'm more in the "fail quickly" camp and would rather ASDF signal a continable error with two restarts:
1. remove the confusing registry entry 2. coerce it to a directory.
In either case, the registry will be corrected so that the cerror will only happen once in a session. Also, if the user fixes the root problem, it'll only happen once period!
Code example coming shortly, -- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
On Tue, 2009-07-07 at 12:31 +0200, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Why not simply deprecate(or unexport *CENTRAL-REGISTRY*) and add a function REGISTER-ASDF-DIRECTORY that does all necessary checks ?
2009/7/10 Stelian Ionescu sionescu@cddr.org:
On Tue, 2009-07-07 at 12:31 +0200, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Why not simply deprecate(or unexport *CENTRAL-REGISTRY*) and add a function REGISTER-ASDF-DIRECTORY that does all necessary checks ?
And break backwards compatibility?
Please DON'T!
Don't break backwards compatibility without many months of advance notice.
Which reminds me that I better get the XCVB interface right before I push it everywhere. Hence my requesting comments from beta-testers.
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ] I have not yet begun to procrastinate
2009/7/10 Stelian Ionescu sionescu@cddr.org:
On Tue, 2009-07-07 at 12:31 +0200, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Why not simply deprecate(or unexport *CENTRAL-REGISTRY*) and add a function REGISTER-ASDF-DIRECTORY that does all necessary checks ?
I like the idea of adding a helper function.
I don't like the idea of hiding *CENTRAL-REGISTRY*. Given that asdf needs a well-ordered list of directories to traverse (a la PATH on every major OS), the current exported list provides a powerful API.
Here's an actual case which greatly benefits from the registry being an exported special variable.
(let ((*central-registry* (list only-search-here))) (if (asdf:operate 'asdf:load-op :test-package) test-package-found-where-expected error))
Here's a quick sketch of two helpers that should handle most common uses.
(defun register-directory (path &optional (where :last) other) (validate-or-die path) (when other (find-or-die other *central-registry*)) (when (find path *central-registry :test #'same-path) (return)) (setf *central-registry* (ccase where (:first (cons path *central-registry*)) (:last (append *central-registry* (list path))) (:before (append paths-before-other (list path other) paths-after-other)) (:after (append paths-before-other (list other path) paths-after-other))))) (defun deregister-directory (path) (setf *central-registry* (remove path *central-registry*)))
Later, Daniel
Hi Daniel,
I like your sketch but wonder about adding a second interface without removing the first. Since we shouldn't remove the first for both backwards compat and special variable goodness, I learn towards keeping things the same and running the checks late.
On Jul 10, 2009, at 11:37 PM, Daniel Herring wrote:
2009/7/10 Stelian Ionescu sionescu@cddr.org:
On Tue, 2009-07-07 at 12:31 +0200, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Why not simply deprecate(or unexport *CENTRAL-REGISTRY*) and add a function REGISTER-ASDF-DIRECTORY that does all necessary checks ?
I like the idea of adding a helper function.
I don't like the idea of hiding *CENTRAL-REGISTRY*. Given that asdf needs a well-ordered list of directories to traverse (a la PATH on every major OS), the current exported list provides a powerful API.
Here's an actual case which greatly benefits from the registry being an exported special variable.
(let ((*central-registry* (list only-search-here))) (if (asdf:operate 'asdf:load-op :test-package) test-package-found-where-expected error))
Here's a quick sketch of two helpers that should handle most common uses.
(defun register-directory (path &optional (where :last) other) (validate-or-die path) (when other (find-or-die other *central-registry*)) (when (find path *central-registry :test #'same-path) (return)) (setf *central-registry* (ccase where (:first (cons path *central-registry*)) (:last (append *central-registry* (list path))) (:before (append paths-before-other (list path other) paths-after-other)) (:after (append paths-before-other (list other path) paths-after-other))))) (defun deregister-directory (path) (setf *central-registry* (remove path *central-registry*)))
Later, Daniel
asdf-devel mailing list asdf-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/asdf-devel
-- Gary Warren King, metabang.com Cell: (413) 559 8738 Fax: (206) 338-4052 gwkkwg on Skype * garethsan on AIM * gwking on twitter
Stelian Ionescu wrote:
On Tue, 2009-07-07 at 12:31 +0200, Tobias C. Rittweiler wrote:
I think it's bitten pretty much all of us that we at least once tried to push a non-directory-designating filename to *CENTRAL-REGISTRY*.
It's a common pitfalls for newcomers.
Couldn't ASDF signal a warning when it encounters such a thing while grovelling through the registry?
Why not simply deprecate(or unexport *CENTRAL-REGISTRY*) and add a function REGISTER-ASDF-DIRECTORY that does all necessary checks ?
This interface actually wouldn't be as powerful as the ability to set a variable. The ability to set a variable lets us effectively UN-register an ASDF directory just as easily as to register one, and also permits us to arbitrarily reorder the directories assigned to the variable.
If this had been done originally, it might have worked, but at this point the breakage of backward compatibility, etc. seems like a real problem.
It might be possible to provide an ADDITIONAL interface like this as a safer way to add new directories (we'd probably want to offer at-end and at-start as options, so that you could either shadow or backstop existing ASDF directories, the way emacs-lisp's add-hook works), but I don't think we could kill the old variable-based interface.
best, r