* Re: [elpa] master b5f4061: Drop forced lambda's from stream (Bug#30626)
[not found] ` <20190604002519.251AC209A5@vcs0.savannah.gnu.org>
@ 2019-06-04 13:27 ` Stefan Monnier
2019-06-04 15:43 ` Noam Postavsky
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2019-06-04 13:27 UTC (permalink / raw)
To: Noam Postavsky; +Cc: emacs-devel
> Let the stream id distinguish between forced and unforced stream
> values. When the value is forced, replace the lambda with its result.
> This lets the lambda and anything it references be garbage collected.
Doesn't the same "memory leak" affect thunks?
How 'bout the patch below
Stefan
diff --git a/lisp/emacs-lisp/thunk.el b/lisp/emacs-lisp/thunk.el
index e1370c4591..8d28570dc2 100644
--- a/lisp/emacs-lisp/thunk.el
+++ b/lisp/emacs-lisp/thunk.el
@@ -54,16 +54,15 @@ thunk-delay
"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.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [elpa] master b5f4061: Drop forced lambda's from stream (Bug#30626)
2019-06-04 13:27 ` [elpa] master b5f4061: Drop forced lambda's from stream (Bug#30626) Stefan Monnier
@ 2019-06-04 15:43 ` Noam Postavsky
2019-06-04 16:58 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Noam Postavsky @ 2019-06-04 15:43 UTC (permalink / raw)
To: Stefan Monnier; +Cc: Emacs developers
On Tue, 4 Jun 2019 at 09:27, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > Let the stream id distinguish between forced and unforced stream
> > values. When the value is forced, replace the lambda with its result.
> > This lets the lambda and anything it references be garbage collected.
>
> Doesn't the same "memory leak" affect thunks?
Yes.
> How 'bout the patch below
Looks good to me. I would have done something like that if I'd thought of it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [elpa] master b5f4061: Drop forced lambda's from stream (Bug#30626)
2019-06-04 15:43 ` Noam Postavsky
@ 2019-06-04 16:58 ` Stefan Monnier
0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2019-06-04 16:58 UTC (permalink / raw)
To: Noam Postavsky; +Cc: Emacs developers
>> > Let the stream id distinguish between forced and unforced stream
>> > values. When the value is forced, replace the lambda with its result.
>> > This lets the lambda and anything it references be garbage collected.
>> Doesn't the same "memory leak" affect thunks?
> Yes.
Thanks, pushed,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-04 16:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20190604002517.28469.52294@vcs0.savannah.gnu.org>
[not found] ` <20190604002519.251AC209A5@vcs0.savannah.gnu.org>
2019-06-04 13:27 ` [elpa] master b5f4061: Drop forced lambda's from stream (Bug#30626) Stefan Monnier
2019-06-04 15:43 ` Noam Postavsky
2019-06-04 16:58 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.