summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/thunk.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/emacs-lisp/thunk.el')
-rw-r--r--lisp/emacs-lisp/thunk.el19
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index e1370c45911..8d28570dc2a 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -54,16 +54,15 @@
"Delay the evaluation of BODY."
(declare (debug t))
(cl-assert lexical-binding)
- (let ((forced (make-symbol "forced"))
- (val (make-symbol "val")))
- `(let (,forced ,val)
- (lambda (&optional check)
- (if check
- ,forced
- (unless ,forced
- (setf ,val (progn ,@body))
- (setf ,forced t))
- ,val)))))
+ `(let (forced
+ (val (lambda () ,@body)))
+ (lambda (&optional check)
+ (if check
+ forced
+ (unless forced
+ (setf val (funcall val))
+ (setf forced t))
+ val))))
(defun thunk-force (delayed)
"Force the evaluation of DELAYED.