License:Public Domain, Load it with Quicklisp:(ql:quickload "first-time-value")
Library type:Macro, Project complexity:Trivial
first-time-value returns the result of evaluating a form in the current lexical and dynamic context the first time it's encountered, and the cached result of that computation on subsequent evaluations.
This package will be mostly designed for explicit qualification of symbols if it ever exports more symbols, such as first-time-value:foo.
form => object
Arguments and Values
form -- A form. Evaluated as described below.
object -- An object. The primary value returned by form the first time it evaluates successfully (without performing a non-local exit).
On first evaluation, first-time-value attempts to evaluate form in the current lexical and dynamic context and cache the primary value it returns, and return that value.
If form performed a non-local exit, then the next evaluation of this first-time-value call will perform the aforementioned steps again.
On subsequent evaluations after a successful evaluation of form, first-time-value ignores form and returns the value that was previously cached.
first-time-value is similar to load-time-value, but evaluates its form in the current lexical and dynamic environment instead of in a null environment, and at the time that code at that location would normally be executed instead of at load time.