Re: (asdf:oos 'asdf:unload-op 'cl-spont)
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Mon, 30 Oct 2006 20:54:45 +0100
"Ralph Allan Rice" <ralph.rice@xxxxxxxxx> writes:
I did do something similar to what Pascal suggested, but I always
wondered about REQUIRE. The CLHS states that REQUIRE is implementation
defined. CLISP has REQUIRE, but it does not hook into ASDF. So, I
attempted to redefine REQUIRE in two different ways, one way was to
redefine as a function:
; SLIME 2006-04-20
CL-USER> (defun require (symbol) (asdf:oos 'asdf:load-op symbol))
WARNING: DEFUN/DEFMACRO: redefining function REQUIRE in top-level, was
defined
in D:\gnu\clisp\current\build-O-mingw\defs1.fas
REQUIRE
CL-USER> (require 's-xml)
; loading system definition from C:\lisp\registry\s-xml.asd into
#<PACKAGE ASDF0>
;; Loading file C:\lisp\registry\s-xml.asd ...
; registering #<SYSTEM :S-XML #x19F4F251> as S-XML
[...]
0 errors, 0 warnings
NIL
The second way was a macro:
Better to keep it a function. Somebody might be doing:
(map nil (function require) '(:cl-x :cl-y :cl-z))
Barring the fact that I created a non-standard redefinition of REQUIRE,
I think this has some value. However, the warning about the
redefinition of REQUIRE makes me think that this solution has other
consequences that are not clear to me. That's why I never actually used
this solution. Can anyone shed some light on this subject?
REQUIRE takes an optional second argument, and when it's given, it's
portable and relatively precisely defined (only the result is not
defined). If you override it, you should keep this sematics.
(REQUIRE "MODULE" '(#P"/some/module/file1.lisp"
#P"/some/module/file2.lisp"
;; ...
#P"/some/module/fileN.lisp"))
When it's not given, I've no idea what REQUIRE does. We'd have to
read the implementation notes or source code.
(defun ensure-list (list-designator)
(if (listp list-designator)
list-designator
(list list-designator)))
(defvar *original-require* (symbol-function 'require))
(#+clisp ext:without-package-lock #+clisp ("COMMON-LISP")
#-clisp progn
;; A minimal conformant implementation of REQUIRE would be:
(defun require (module-name &optional pathname-list)
(check-type module-name (or string symbol character))
(unless (member (string module-name) *modules* :test (function string=))
(let ((pathname-list (ensure-list pathname-list)))
(if pathname-list
(dolist (path pathname-list) (load path))
(implementation-dependant-part-of-require module-name))))))
;; So you can modify the implementation dependant part as you want:
(defun implementation-dependant-part-of-require (module-name)
;; Do whatever you want here.
;; For example, if module-name is not a loadable asdf-system,
;; we could fallback to the original REQUIRE:
;; http://clisp.cons.org/impnotes/system-dict.html#require
(or (and (ignore-errors (asdf:oos 'asdf:load-op module-name))
;; PROVIDE is normally done by one of the loaded files.
;; I don't know if ASDF does it.
(provide (intern (string module-name) "KEYWORD")))
(funcall *original-require* module-name)))
--
__Pascal Bourguignon__ http://www.informatimago.com/
NOTE: The most fundamental particles in this product are held
together by a "gluing" force about which little is currently known
and whose adhesive power can therefore not be permanently
guaranteed.
.
- References:
- (asdf:oos 'asdf:unload-op 'cl-spont)
- From: JohnFredCee
- Re: (asdf:oos 'asdf:unload-op 'cl-spont)
- From: bradb
- Re: (asdf:oos 'asdf:unload-op 'cl-spont)
- From: Pascal Bourguignon
- Re: (asdf:oos 'asdf:unload-op 'cl-spont)
- From: Ralph Allan Rice
- (asdf:oos 'asdf:unload-op 'cl-spont)
- Prev by Date: Re: How to learn how much heap is used (in Allegro Common Lisp)?
- Next by Date: Re: nested presentations
- Previous by thread: Re: (asdf:oos 'asdf:unload-op 'cl-spont)
- Next by thread: nested presentations
- Index(es):