14 ms·
In the TXR Lisp compiler load-time (what load-time-value is called: of course there is always a value, so why mention it) is used in the implementation of lamb
by kazinator 5y ago
In the TXR Lisp compiler load-time (what load-time-value is called: of course there is always a value, so why mention it) is used in the implementation of lambda hoisting.
E.g. if your compiler doesn't have lambda hoisting, you cna manually do it like this:
(defun my-fun (...)
(let ((fun (load-time (lambda (...))))
...))
This works if the function doesn't make any references to the lexical environment of the surrounding function. Then the lambda gets instantiated once and becomes a "virtual literal" in the loaded code; calls to my-fun no longer have to construct a closure; they just pull it out of the static data, where it is in a kind of fixed register at a known position.
The compiler has to recognize cases when this can be done automatically and make it so.