From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tomas Hlavaty Newsgroups: gmane.emacs.devel Subject: Re: using finalizers Date: Sat, 01 Jan 2022 21:25:09 +0100 Message-ID: <877dbjkxui.fsf@logand.com> References: <878rw1pvcw.fsf@logand.com> <875yr5p9t3.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7101"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 01 21:27:45 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n3kyc-0001Tr-Ec for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Jan 2022 21:27:42 +0100 Original-Received: from localhost ([::1]:50678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3kyb-0002Ug-7Z for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Jan 2022 15:27:41 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3kwF-00013s-7C for emacs-devel@gnu.org; Sat, 01 Jan 2022 15:25:16 -0500 Original-Received: from logand.com ([37.48.87.44]:33636) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3kwD-0007oL-FX for emacs-devel@gnu.org; Sat, 01 Jan 2022 15:25:14 -0500 Original-Received: by logand.com (Postfix, from userid 1001) id F41C019EC87; Sat, 1 Jan 2022 21:25:10 +0100 (CET) X-Mailer: emacs 27.2 (via feedmail 11-beta-1 I) In-Reply-To: Received-SPF: pass client-ip=37.48.87.44; envelope-from=tom@logand.com; helo=logand.com X-Spam_score_int: 0 X-Spam_score: -0.0 X-Spam_bar: / X-Spam_report: (-0.0 / 5.0 requ) SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:283816 Archived-At: On Sat 01 Jan 2022 at 12:00, Stefan Monnier 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.