This may be a dumb question, but:
Suppose an expression depends only on literals or on other expressions that also depend only on literals; will the compiler evaluate this at compile time?
Suppose I,
(def a (some-time-consuming-function some-literal)) (def b (some-other-time-consuming-function a))
Will both b and a be fully evaluated at compile time so that the user does not suffer?
EDIT: Thank you very much, all the answers were very helpful.
EDIT 6.6.2011: It turns out that if you try to use this technique to precompute a very large data structure, it is easy to make class files that are too large to load. In these cases, you want to create a file that will be read, not a class file that will be loaded. The matrix tricks described in these answers should only be used when the return value is not an overly large structure.
Error issued: "java.lang.ClassFormatError: Invalid index for this class" See this thread for a discussion of the related situation.
compiler-construction clojure
Rob lachlan
source share