From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#59786: Allowing arbitrary expressions in cl-labels Date: Tue, 29 Oct 2024 10:51:26 -0400 Message-ID: References: <87r0vybl6f.fsf@web.de> <874j4vw0tq.fsf@web.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22958"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 59786@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 29 15:52:30 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1t5na8-0005lV-C7 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 29 Oct 2024 15:52:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t5nZq-0003ly-3x; Tue, 29 Oct 2024 10:52:10 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5nZn-0003ik-HC for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 10:52:07 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t5nZi-0003p0-UE for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 10:52:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=O0R9FAZ0Nadrr0Sesn6WUOliUjFZTaPRmMvVRxd8nYU=; b=MF1B4xChjKM/cFxbTvjVzNBUM8p6pENpM5IdZwqTcNXt2mGRFv16cGNRTs2YS6HV3RdCF/EJA5GWhkbCYJF4TADI/ZZc6ko4CtXt4UbT+1hGVyX+eWc1AN7KVh+5+cO6NbDfjksGo0IG/nB7k8O39O0heE733RbVHC2AH+sAczxnbRroomWL3/lXp9am9T46cW9q+vVRuzjy6Wel6Mj4X0CxjbS0Apr03Jl7Evam6QV4TJup4GK3rvbmnoaslLqUmyvFCnF9yTSaksIGOvCUrb170SuxwO/P29I+ORtxXNxdMxAVkedARWGr+UzAsRDy0aVtP3oopORb7T2Wv6LXog==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1t5nZi-0007Vd-Eo for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 10:52:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Oct 2024 14:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59786 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-Cc: "Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors" , 59786@debbugs.gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.173021349928842 (code B ref -1); Tue, 29 Oct 2024 14:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Oct 2024 14:51:39 +0000 Original-Received: from localhost ([127.0.0.1]:56762 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5nZK-0007V6-LO for submit@debbugs.gnu.org; Tue, 29 Oct 2024 10:51:39 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:32864) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1t5nZG-0007Ut-Ix for submit@debbugs.gnu.org; Tue, 29 Oct 2024 10:51:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5nZE-0003X7-G0 for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 10:51:32 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t5nZC-0003ii-2a for bug-gnu-emacs@gnu.org; Tue, 29 Oct 2024 10:51:32 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id B490E807A8; Tue, 29 Oct 2024 10:51:27 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1730213486; bh=awWPCh+NnQMYA1DEyx6f6pUmg1IrY7cZsqm1M1t4wOA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=C1Wc+LCSd73rIdVDBoow1128D/A7RM7VGJgoXnn8RubGXmLb8rBjiu2BW0ACtxOjt yve4Fm8ZIPfAgBzQIOEXiKPiJM37nfGs6mwAEtcgcig4eDXKvTNPXFFPXnLeO2OB5W p8ttb/mRWjk97vMbovi1UeQ94Phcip/raa5a1uekiz8qCsVl1u9DXRCbiUeqiXBWIV 9aoC0gOkE7rpawhqhnwBHwOf/mDrdHOJYJ2v6GkkKtzZjh/PGaROl5d7VPyrHF8Y4/ J6tv+6jfWYbG7y4aUeaZBi6DeU3qgVU6cKHbOms10STHo3d60AHRjm2r6eZXZyxduN yLCFzLLirKi6w== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id DBC5A80966; Tue, 29 Oct 2024 10:51:26 -0400 (EDT) Original-Received: from alfajor (modemcable094.121-70-69.static.videotron.ca [69.70.121.94]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B496B120346; Tue, 29 Oct 2024 10:51:26 -0400 (EDT) In-Reply-To: <874j4vw0tq.fsf@web.de> (Michael Heerdegen's message of "Tue, 29 Oct 2024 13:28:01 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -9 X-Spam_score: -1.0 X-Spam_bar: - X-Spam_report: (-1.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.335, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:294494 Archived-At: >> -forms of the function body. FUNC is defined in any BODY, as well >> +forms of the function body. FUNC is defined in any BODY or EXP, as well > ^^^^^^ > This is unfortunately not correct, e.g. > > (cl-labels ((even (if (odd 5) > (lambda (x) (if (= x 0) t (odd (1- x)))) > #'ignore)) > (odd (lambda (x) (if (= x 0) nil (even (1- x)))))) > (list (even 42) (odd 42))) > > ~~> funcall: Symbol's function definition is void: nil This is normal. Same happens with (letrec ((even (if (funcall odd 5) (lambda (x) (if (= x 0) t (funcall odd (1- x)))) #'ignore)) (odd (lambda (x) (if (= x 0) nil (funcall even (1- x)))))) (list (funcall even 42) (funcall odd 42))) This construct is used for recursive functions, not recursive expressions. Recursive expressions can't be handled without going for some kind of lazy evaluation strategy which is quite difficult to pull off in a macro. > Dunno how useful it is at all that the EXPs can use any of the defined > functions. As mentioned (admittedly, a long time ago), the purpose is to *compute* the recursive functions, e.g. (cl-labels ((f1 (if (fboundp 'foo) (lambda (x) ... (f1 ..) ...) (lambda (x) ... (f1 ..) ...)))) ...) My original motivation is to define recursive oclosures (for PEG): (cl-labels ((f1 (oclosure-lambda ... (f1 ..) ...))) ...) - Stefan