Topic: Lisp
Both uri-template and css-lite provide optional support for generating JavaScript templates via Parenscript. However, I did not want to make Parenscript a required dependency for either library.
Previously, this was implemented using the #+parenscript
read-time
conditional in the source files.
That worked ok if you loaded Parenscript before loading css-lite, but there were two problems:
.fasl
s compiled with
Parenscript into a fresh Lisp image without loading Parenscript
first, you would get an error.
Both of these error stem from the fact that ASDF did not know anything about the optional Parenscript dependency.
Didier Verna has
written about optional
ASDF dependencies previously (make sure to read the asdf-devel
thread on optional dependencies Didier references). In short,
relying on ASDF's :weakly-depends-on
seems quite hairy.
I think I found a simple alternate solution for uri-template that seems to work: put all the Parenscript-dependent code into one file, and then use read-time conditionals in the uri-template.asd list of files like so:
:components ((:file "package")
...
(:file "destructure-uri")
#+parenscript (:file "parenscript-implementation")
)
You can see the full implementation in the latest patch to uri-template.
Let me know if you have any ideas about this technique, or optional dependencies in general.
The solution I recommended to the DWIM guys, who adopted it, is to create additional ASDF packages:
uri-template uri-template+parenscript css-lite css-lite+parenscript
That's the only way that preserves the sanity of things, independently from the order in which you compile things, etc.
asd files are cheap.