[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using finalizers
From: |
Tomas Hlavaty |
Subject: |
Re: using finalizers |
Date: |
Sat, 01 Jan 2022 21:25:09 +0100 |
On Sat 01 Jan 2022 at 12:00, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> One more question: Because make-finalizer in Emacs Lisp does not take
>> the object into account,
>
> Not sure what you mean by "the object" here.
In Common Lisp, the usual semantics is: call this thunk when this object
gets collected. I pass the object and thunk and make-finalizer does the
rest.
In Emacs Lisp, the semantics is: call this thunk when the returned
finalizer gets collected. So, if I want to finalize my object, I have
too keep the reference to the finalizer.
>> 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.
>
> And I definitely don't know what you mean by "the reference", so I have
> no idea why a smart compiler would be able to eliminate it.
In Emacs Lisp, my object itself needs to keep the finalizer around,
otherwise it would get finalized.