WeYu wrote:Faslpath implements this. Have a look, feedback welcome.
Wasn't any cliki page for it,
here is one for starters.
Came here to suggest making an alternative macro that makes asdf files and defpackage forms at the same time.Seems like faslpath is not entirely unlike it. Still, i think i prefer the idea of automatically making asdf files better, and i don't like the idea of having to change the names of packages to use fasl path, and asdf seems pretty standard atm, so using that might be handy.
How about implementing it by hooking it into defpackage. I considered going via a defpackage* or just some macro, but that would add a dependency;
*macroexpand-hook*, but that seems like the wrong way to use that feature, how about just:
Code: Select all
(defvar *old-defpackage* (macro-function 'defpackage)
"Default defpackage macro to be overridden. Won't overwrite itself when called twice because it is a defvar.")
(defun register-package (form)
;Hopefully can use *compile-file-truename*, *load-file-truename* *load-pathname* to figure out where the file is.
;Then make/overwrite .asd file in desired location.
...)
(defmacro cl::defpackage (&rest stuff)
(register-package form)
(funcall *old-defpackage* `(defpackage ,@stuff) nil))
Hmm now i think about it, i could make
expression-hook do it, an expression hook can easily converted to a *macroexpand-hook* with
Code: Select all
(defun to-macroexpand-hook (expr-hook)
(lambda (expander form env)
(declare (ignore expander env))
(funcall expr-hook form)))
Difference is that *expression-hook* is also called upon functions, variables, etc. (What is 'env' for anyway, don't we have special variables? I guess i will have to find out; found that there are libs i can't scan seemingly due to env being nil when expr-hook calls it.)