(with-stolen-alist name form)ensures that
nameis a fast alist at the
start of the execution of
form. At the end of execution, it ensures that
nameis a fast alist if and only if it was originally. That is, if
namewas not a fast alist originally, its hash table link is freed, and if
it was a fast alist originally but its table was modified during the execution
form, that table is restored. Note that any extended table created from
the original fast alist during
formmust be manually freed.
Major Section: HONS-AND-MEMOIZATION
with-stolen-alist just returns
Under the hood, we cause
alist to become a fast alist before executing
form, and we check the various conditions outlined above before returning
the final value.
with-stolen-alist will cause logically tail-recursive functions
not to execute tail-recursively if its cleanup phase happens after the
tail-recursive call returns.