From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: using finalizers Date: Thu, 30 Dec 2021 22:29:08 -0500 Message-ID: References: <878rw1pvcw.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="40783"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Tomas Hlavaty , emacs-devel@gnu.org To: LdBeth Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Dec 31 04:35:32 2021 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 1n38hW-000ALm-Ib for ged-emacs-devel@m.gmane-mx.org; Fri, 31 Dec 2021 04:35:30 +0100 Original-Received: from localhost ([::1]:47706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n38hV-0007i4-Hd for ged-emacs-devel@m.gmane-mx.org; Thu, 30 Dec 2021 22:35:29 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:39586) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n38bg-0000wB-Mu for emacs-devel@gnu.org; Thu, 30 Dec 2021 22:29:28 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52460) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n38bd-0002wZ-UG for emacs-devel@gnu.org; Thu, 30 Dec 2021 22:29:27 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 4CAF11001CB; Thu, 30 Dec 2021 22:29:23 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 94101100173; Thu, 30 Dec 2021 22:29:17 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1640921357; bh=hkbtuezCabr8NEP38Ns7f4KQ63CkNQT59DvwkK/9u7E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=Yh6hxfBIUpUnmDtZJgJsb+hx6E8koa4Lu/Mjp5wKYvltSi0oPTmuqSf9yi/UzLPGt 0Q+N9Zgf6g96p5jIQf7c9ElFp7o0ejYL+eqIwkVlnLIezPuJn3jjtYEvdbd0zApeca d9aGuHMnXXonpIf6ThOm2G4VyT5YDRyIGS4axVVPOhvlRe9Oq8qO6g4vXqgXTHiboQ Dta6uZDYa0zc+V119J3DSIpbavmL11AdxhgFAC5sZ+piaGqlGmgR/jgKaVjG0KYvs5 oI6eyaxjzI26rCg1VlABDywpr3yjmcuv0IeipqMXlhqblRIVh0gRdcAW+o3t8T1M7g lOCyuyrcRcRWA== Original-Received: from ceviche (unknown [216.154.30.173]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5D03312022C; Thu, 30 Dec 2021 22:29:17 -0500 (EST) In-Reply-To: (LdBeth's message of "Fri, 31 Dec 2021 10:46:20 +0800") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=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:283696 Archived-At: > You are probably taking the wrong assumption about the effect of letrec > > (macroexpand '(letrec ((more (make-finalizer close)) > (close (lambda () > (setq bar t)))) > (lambda () > (when more > (pop x))))) > > ==> (let (more close) > (setq more (make-finalizer close)) > (setq close (lambda nil (setq bar t))) > (lambda nil (when more (pop x)))) Indeed, the code needs to swap `more` and `close`. > I think Common Lisp doesn't have letrec in the standard. And you are > proabaly taking the assumption that ELisp's letrec works as well as > Scheme's one. But it is not. I don't think Scheme's `letrec` works any differently in this respect, except that instead of nil, variables get a special "void like" value before they're initialized. In the above code, the real bug I can see which we should fix is that `make-finalizer` should signal an error if its arg is not a function. Stefan