Enhance AOT compilation process to emit classfiles only for explicitly-specified namespaces
Key details
Description
Why This Was Declined
The current behavior of transitive compilation is a valuable semantic. It is arguably essential to e.g. AOT protocols ahead of their call sites.
On the other hand, you should not ship AOT compiled classes for which your project is not the source. As worded in the original ticket: "Having the option of shipping either all AOT-compiled classfiles or mixed source/AOT depending upon one's distribution requirements would make that phase of work with a clojure codebase significantly easier and less error-prone."
This latter goal can be accomplished by keeping "what you compile" and "what you ship" cleanly separate. The compiler does not know or care about the latter, and tools can automate this with e.g. boot's sift.
The only question in my mind is what the default should be. We're all used to the current behaviour, but I'd guess that any nontrivial project where the form of the distributable matters (i.e. the source/AOT mix), providing as much control as possible by default makes the most sense. Given the tooling that most people are using, it's trivial (and common practice, IIUC) to provide a comprehensive list of namespaces one wishes to compile, so making that the default shouldn't be a hurdle to anyone. If an escape hatch is desired, a --transitive switch to clojure.lang.Compile could be added.
Why This Was Declined
The current behavior of transitive compilation is a valuable semantic. It is arguably essential to e.g. AOT protocols ahead of their call sites.
On the other hand, you should not ship AOT compiled classes for which your project is not the source. As worded in the original ticket:
"Having the option of shipping either all AOT-compiled classfiles or mixed source/AOT depending upon one's distribution requirements would make that phase of work with a clojure codebase significantly easier and less error-prone."
This latter goal can be accomplished by keeping "what you compile" and "what you ship" cleanly separate. The compiler does not know or care about the latter, and tools can automate this with e.g. boot's
sift
.Historical Context
This was originally/erroneously reported by Howard Lewis Ship in the clojure-contrib assembla:
The only question in my mind is what the default should be. We're all used to the current behaviour, but I'd guess that any nontrivial project where the form of the distributable matters (i.e. the source/AOT mix), providing as much control as possible by default makes the most sense. Given the tooling that most people are using, it's trivial (and common practice, IIUC) to provide a comprehensive list of namespaces one wishes to compile, so making that the default shouldn't be a hurdle to anyone. If an escape hatch is desired, a --transitive switch to clojure.lang.Compile could be added.