[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using finalizers
From: |
Tomas Hlavaty |
Subject: |
Re: using finalizers |
Date: |
Fri, 31 Dec 2021 07:28:40 +0100 |
On Fri 31 Dec 2021 at 10:46, LdBeth <andpuke@foxmail.com> wrote:
>>>>>> In <878rw1pvcw.fsf@logand.com> Tomas Hlavaty <tom@logand.com> wrote:
> You are probably taking the wrong assumption about the effect of letrec
> So, `close' is nil and the lambda is never set as the finalizer.
You are right, the order was wrong.
>> What is the expected example usage of finalizers in Emacs Lisp?
>> How can I verify, that my finalizer works?
>
> (setq bar nil)
> (setq foo (make-finalizer (lambda () (setq bar t))))
> (setq foo nil)
> (garbage-collect)
> bar ; => t
Nice, that works.
One more question: Because make-finalizer in Emacs Lisp does not take
the object into account, I have to make sure to hold the reference to
the finalizer somehow. However, this might not be trivial, because a
smart compiler could eliminate the reference. Is this not an issue?
Shouldn't make-finalizer take the object as an argument and not rely on
me holding the reference explicitly?
Thank you!
Re: using finalizers, Eli Zaretskii, 2021/12/31
Re: using finalizers, LdBeth, 2021/12/31