emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: thunk.el: Document that thunk-force == funcall?


From: Tomas Hlavaty
Subject: RE: thunk.el: Document that thunk-force == funcall?
Date: Thu, 19 Nov 2020 00:25:17 +0100

On Thu 19 Nov 2020 at 00:05, Tomas Hlavaty <tom@logand.com> wrote:
> (let ((void (list nil)))
>   (defun memoize (thunk)
>     (let ((z void))
>       (lambda ()
>         (when (eq z void)
>           (setq z (funcall thunk)))
>         z))))

it would be better to "free" the thunk:

(let ((void (list nil)))
  (defun memoize (thunk)
    (let ((z void))
      (lambda ()
        (when (eq z void)
          (setq z (funcall thunk)
                thunk nil))
        z))))

interesting drawback of thunk.el implementation is that thunk-delay does
not allow that and whatever is captured stays captured even after
thunk-force.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]