[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using finalizers
From: |
Tomas Hlavaty |
Subject: |
Re: using finalizers |
Date: |
Sun, 02 Jan 2022 00:47:00 +0100 |
On Sat 01 Jan 2022 at 18:18, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> > Do you have concrete cases where this difference introduces a
>> > difficulty?
Well, maybe not difficulty but inconvenience and potential future
difficulty. I found make-finalizer surprising and inconvenient.
But LdBeth pointed out some interesting things I need to read about.
> I miswrote, by "concrete" I meant a real-word use, no a made-up case.
It was a reduced case of:
(defun directory-brook (directory)
(let (d)
(letrec ((close (lambda ()
(when d
(close-directory d)
(setq d nil
more nil))))
(more (make-finalizer close)))
(lambda ()
(when more
(unless d
(setq d (open-directory directory)))
(let (z (again t))
(while again
(setq z (read-directory d))
(cond
((equal z "."))
((equal z ".."))
(z (setq again nil))
(t (setq again nil) (funcall close))))
z))))))
There are bits missing but it should give you an idea.
> [ But at least, now I understand what you meant by the fact that the
> behavior depends on the byte-compiler's analysis. ]
Great, that was difficult for me to express.
> In any case, I don't think we have much experience with the current
> `make-finalizer` API (nor with other finalizer APIs) in ELisp, so
> I think there's room for tweaks/changes. But it should be based
> on concrete cases in real world ELisp code.
Understand, thank you.
Re: using finalizers, Tomas Hlavaty, 2022/01/01
Re: using finalizers, Tomas Hlavaty, 2022/01/01