|
|
|
|
|
by kazinator
1351 days ago
|
|
Speaking of Lisp, macros and compile-time evaluation, it's amazing that there isn't a standard macro macro-time which evaluates its argument and replaces it with the quoted object resulting from its evaluation. It's so easy to write! Blatant, arbitrary compile-time evaluation (other than code transformation) is not that common in Lisp programs; which could be why such a macro wouldn't be used a lot. For complicated, calculated constants, the Common Lisp defconstant has certain semantics that work in that space, where responsibilities are foisted onto the programmer: [A]n implementation may choose to evaluate the value-form [of defconstant] at compile time, load time, or both. Therefore, users must ensure that the initial-value can be evaluated at compile time (regardless of whether or not references to name appear in the file) and that it always evaluates to the same value. In Common Lisp, arguably, defconstant is the mechanism of choice for blatant compile-time evaluation for actually obtaining a value from a complex expression which is thereafter treated as a constant. And its semantics isn't precise enough for the task of retrieving something from a specific environment. Using defconstant to access a file in the compilation environment won't work if the evaluation is done at load time. In any case, defconstant looks very similar to these constant expression mechanisms that are cropping up. |
|