[asdf-devel] Guard against (push "/foo/bar" asdf:*central-registry*)
dherring at tentpost.com
Sat Jul 11 03:37:00 UTC 2009
2009/7/10 Stelian Ionescu <sionescu at 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)
Here's a quick sketch of two helpers that should handle most common uses.
(defun register-directory (path &optional (where :last) other)
(find-or-die other *central-registry*))
(when (find path *central-registry :test #'same-path)
(cons path *central-registry*))
(append *central-registry* (list path)))
(list path other)
(list other path)
(defun deregister-directory (path)
(remove path *central-registry*)))
More information about the asdf-devel