Function: with-memoization

with-memoization is a macro defined in elisp-doc-extract.el.

Signature

(with-memoization PLACE &rest CODE)

Documentation

Return the value of CODE and stash it in PLACE.

If PLACE's value is non-nil, then don't bother evaluating CODE and return the value found in PLACE instead.

Source Code

;; Defined in /nix/store/sszxjnwzazz01486dqxi6cpi1wxyg88v-emacs-28-2/share/emacs/28.2/site-lisp/elisp-doc-extract.el
;; Polyfill
(eval-and-compile
  (when (not (fboundp 'with-memoization))
    (defmacro with-memoization (place &rest code)
      "Return the value of CODE and stash it in PLACE.
If PLACE's value is non-nil, then don't bother evaluating CODE
and return the value found in PLACE instead."
      (declare (indent 1) (debug (gv-place body)))
      (gv-letplace (getter setter) place
        `(or ,getter
             ,(macroexp-let2 nil val (macroexp-progn code)
                `(progn
                   ,(funcall setter val)
                   ,val)))))))