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: Sun, 02 Jan 2022 00:47:00 +0100 Message-ID: <87tuenj9xn.fsf@logand.com> References: <878rw1pvcw.fsf@logand.com> <875yr5p9t3.fsf@logand.com> <877dbjkxui.fsf@logand.com> <8735m7kqvq.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="24915"; 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 Sun Jan 02 00:48:12 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 1n3o6e-0006Hp-K3 for ged-emacs-devel@m.gmane-mx.org; Sun, 02 Jan 2022 00:48:12 +0100 Original-Received: from localhost ([::1]:38990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n3o6d-0003Po-IP for ged-emacs-devel@m.gmane-mx.org; Sat, 01 Jan 2022 18:48:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42704) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3o5Z-000244-HZ for emacs-devel@gnu.org; Sat, 01 Jan 2022 18:47:05 -0500 Original-Received: from logand.com ([37.48.87.44]:41398) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n3o5X-0005uP-Va for emacs-devel@gnu.org; Sat, 01 Jan 2022 18:47:05 -0500 Original-Received: by logand.com (Postfix, from userid 1001) id AB65D19EC87; Sun, 2 Jan 2022 00:47:01 +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:283836 Archived-At: On Sat 01 Jan 2022 at 18:18, Stefan Monnier 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.