[Feature Request] Defer loading of specified files until dependency system is loaded
Hello,
I had some issues with account creation so the original of this issue got removed, and I am recreating it.
I and some others desire an ability to defer the loading of a file until a dependency system is loaded, with said file not being loaded at all if the dependency system never gets loaded. For example:
(defsystem :foo
:serial t
:components ((:file "foo")
(:file "bar-compatibility" :load-after (:bar))))
In the above example, loading the system :foo
would load the file foo.lisp
, and then check if the system :bar
is already loaded. If it is, the file bar-compatibility.lisp
would be loaded. If it is not, then the file bar-compatibility.lisp
would be registered to be loaded if/when the system :bar
is loaded. This is different from the normal asdf dependencies in that it does not try to load :bar
in order to load bar-compatibility.lisp
, rather it waits until :bar
is loaded either manually or as an explicit dependency of another system before loading bar-compatibility.lisp
, and may never load the file at all if :bar
is never loaded. While this simple example above says to load a file after :bar
is loaded, it would be nice if this could be specified for all components (systems, modules, etc). In addition, this should not depend upon the system :bar
already being known by asdf (I am unsure of how practical this is).
I am unsure what the best way of implementing this functionality would be. I've played around a little bit with asdf, and my current approach is to add an after method to the operate
generic function, which specializes upon load-op
and system
. This method runs a hook with the system being loaded as its only argument. Then instead of adding files which should be loaded after another system to the system definition, functions are defined to load the files if the system being loaded is the denoted system, and the function is hung on the aforementioned hook. This approach is clunky, inelegant, and results in files sometimes being loaded multiple times when they dont need to be. There is likely a better solution, but I'm not familiar enough with how asdf operates internally to implement it at this point.
If this is already described in the manual, please point me towards the appropriate section or subsection, as in my reading I couldn't find it.