From unknown Tue Jun 17 22:12:48 2025 X-Loop: don@donarmstrong.com Subject: bug#748: Elisp: lexical-let and cyclic structures Reply-To: michael_heerdegen@web.de, 748@debbugs.gnu.org Resent-From: Michael Heerdegen Original-Sender: Michael_Heerdegen@web.de Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Wed, 20 Aug 2008 14:05:05 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 748 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by submit@emacsbugs.donarmstrong.com id=B.12192405795013 (code B ref -1); Wed, 20 Aug 2008 14:05:05 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-7.8 required=4.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 Aug 2008 13:56:19 +0000 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7KDuFYQ005006 for ; Wed, 20 Aug 2008 06:56:17 -0700 Received: from mail.gnu.org ([199.232.76.166]:49866 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1KVo9H-0001Ft-DD for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:54:55 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1KVoAT-0000Tx-US for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:56:14 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:45710) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KVoAT-0000TW-HX for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:56:09 -0400 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 8157EEB8BFE1 for ; Wed, 20 Aug 2008 15:56:05 +0200 (CEST) Received: from [217.185.137.22] (helo=debian) by smtp05.web.de with asmtp (WEB.DE 4.109 #226) id 1KVoAO-00037w-00 for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 15:56:04 +0200 From: Michael Heerdegen To: emacs-pretest-bug@gnu.org Date: Wed, 20 Aug 2008 15:57:16 +0200 Message-Id: <1219240636.0@debian> Sender: Michael_Heerdegen@web.de X-Sender: michael_heerdegen@web.de X-Provags-ID: V01U2FsdGVkX18g64pMWVCWpWPcfiYzXqe+V4YfbnpJ//DeWIAe /e+Nqnx7i/AtPVV3/EnlKYTDXPkVw0RzjNCDYrUGJzWAJpV9ql i/BOocuL7wVCdrUjEEvg== X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 When using the reader constructs `#N=' and `#N#' for cyclic structures, lexical-let sometimes produces errors which don't occur with let. Example: Eval the following: (defun f (start) (lexical-let (start start) ;; return a closure #1=(lambda (x) (if (= x start) x (+ x (#1# (1- x))))))) Then evaluating f ends with an error: (f 3) "Variable binding depth exceeds max-specpdl-size" The problem also occurs without lambdas. Examples: (let () '#1=(#1#)) ;; ==> (#0) (lexical-let () '#1=(#1#)) ;; Error (let ((x '#1=(#1#))) (lexical-let () x)) ;; ==> (#0) `#1=(#1#) ;; Error From unknown Tue Jun 17 22:12:48 2025 X-Loop: don@donarmstrong.com Subject: bug#748: Elisp: lexical-let and cyclic structures Reply-To: Stefan Monnier , 748@debbugs.gnu.org Resent-From: Stefan Monnier Resent-To: bug-submit-list@lists.donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Thu, 21 Aug 2008 01:20:03 +0000 Resent-Message-ID: Resent-Sender: don@donarmstrong.com X-Emacs-PR-Message: report 748 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Received: via spool by 748-submit@emacsbugs.donarmstrong.com id=B748.121928115625790 (code B ref 748); Thu, 21 Aug 2008 01:20:03 +0000 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-7.3 required=4.0 tests=AWL,BAYES_00,HAS_BUG_NUMBER autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at 748) by emacsbugs.donarmstrong.com; 21 Aug 2008 01:12:36 +0000 Received: from smtp-04.arnet.com.ar (smtp-04.arnet.com.ar [200.45.191.26]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with SMTP id m7L1CTmC025778 for <748@emacsbugs.donarmstrong.com>; Wed, 20 Aug 2008 18:12:33 -0700 Received: (qmail 11956 invoked from network); 21 Aug 2008 01:10:37 -0000 Received: from unknown (HELO ceviche.home) (200.117.157.213) by 0 with SMTP; 21 Aug 2008 01:10:36 -0000 Received: by ceviche.home (Postfix, from userid 20848) id E1851B404F; Wed, 20 Aug 2008 21:12:22 -0400 (EDT) From: Stefan Monnier To: 748@debbugs.gnu.org Message-ID: References: <1219240636.0@debian> Date: Wed, 20 Aug 2008 21:12:22 -0400 In-Reply-To: <1219240636.0@debian> (Michael Heerdegen's message of "Wed, 20 Aug 2008 15:57:16 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-CrossAssassin-Score: 2 tag +748 wontfix thanks > When using the reader constructs `#N=' and `#N#' for cyclic > structures, lexical-let sometimes produces errors which don't occur > with let. Most programming languages do not accept infinite programs. Elisp is no exception. The fact that you can build cyclic abstract syntax trees and that they sometimes get evaluated correctly is just an accident. I.e. if it hurts, don't do it. > (defun f (start) > (lexical-let (start start) ;; return a closure > #1=(lambda (x) (if (= x start) x > (+ x (#1# (1- x))))))) For this case, I'd recommend to make the recursion explicit, e.g.: (defun f (start) (lexical-let ((start start)) ;; return a closure (labels ((loop (x) (if (= x start) x (+ x (loop (1- x)))))) loop))) -- Stefan From unknown Tue Jun 17 22:12:48 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: michael_heerdegen@web.de Subject: bug#748: closed (Re: bug#748: Elisp: lexical-let and cyclic structures) Message-ID: References: <1219240636.0@debian> X-Gnu-PR-Message: they-closed 748 X-Gnu-PR-Package: emacs X-Gnu-PR-Keywords: wontfix Reply-To: 748@debbugs.gnu.org Date: Sat, 09 Jul 2011 17:52:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1310233922-24052-1" This is a multi-part message in MIME format... ------------=_1310233922-24052-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #748: Elisp: lexical-let and cyclic structures which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 748@debbugs.gnu.org. --=20 748: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D748 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1310233922-24052-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 748-done) by debbugs.gnu.org; 9 Jul 2011 17:51:52 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qfbh0-0006FV-W4 for submit@debbugs.gnu.org; Sat, 09 Jul 2011 13:51:51 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Qfbgz-0006FK-Jg for 748-done@debbugs.gnu.org; Sat, 09 Jul 2011 13:51:49 -0400 Received: from localhost ([127.0.0.1]:38225) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qfbgt-0003TF-Vs; Sat, 09 Jul 2011 13:51:44 -0400 From: Glenn Morris To: 748-done@debbugs.gnu.org Subject: Re: bug#748: Elisp: lexical-let and cyclic structures References: <1219240636.0@debian> X-Spook: Treasury president Perl-RSA CDMA propaganda warfare top X-Ran: :3|vkN=Y$a1upQ,/I59U&+dETSg&%$9VS)wpbA`1l{/.ZDCUfc=\QGdH<(G]Gs{a(AzD{^ X-Hue: red X-Attribution: GM Date: Sat, 09 Jul 2011 13:51:43 -0400 In-Reply-To: (Stefan Monnier's message of "Wed, 20 Aug 2008 21:12:22 -0400") Message-ID: User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.4 (------) X-Debbugs-Envelope-To: 748-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.4 (------) I don't see a need to keep open this particular report, which was marked "wontfix" some time ago. Stefan Monnier wrote: > Most programming languages do not accept infinite programs. Elisp is > no exception. The fact that you can build cyclic abstract syntax trees > and that they sometimes get evaluated correctly is just an accident. > > I.e. if it hurts, don't do it. ------------=_1310233922-24052-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit >From Michael_Heerdegen@web.de Wed Aug 20 06:56:19 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3-bugs.debian.org_2005_01_02 (2007-08-08) on rzlab.ucr.edu X-Spam-Level: X-Spam-Status: No, score=-7.8 required=4.0 tests=AWL,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.2.3-bugs.debian.org_2005_01_02 Received: (at submit) by emacsbugs.donarmstrong.com; 20 Aug 2008 13:56:19 +0000 Received: from fencepost.gnu.org (fencepost.gnu.org [140.186.70.10]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id m7KDuFYQ005006 for ; Wed, 20 Aug 2008 06:56:17 -0700 Received: from mail.gnu.org ([199.232.76.166]:49866 helo=mx10.gnu.org) by fencepost.gnu.org with esmtp (Exim 4.67) (envelope-from ) id 1KVo9H-0001Ft-DD for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:54:55 -0400 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1KVoAT-0000Tx-US for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:56:14 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]:45710) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KVoAT-0000TW-HX for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 09:56:09 -0400 Received: from smtp05.web.de (fmsmtp05.dlan.cinetic.de [172.20.4.166]) by fmmailgate01.web.de (Postfix) with ESMTP id 8157EEB8BFE1 for ; Wed, 20 Aug 2008 15:56:05 +0200 (CEST) Received: from [217.185.137.22] (helo=debian) by smtp05.web.de with asmtp (WEB.DE 4.109 #226) id 1KVoAO-00037w-00 for emacs-pretest-bug@gnu.org; Wed, 20 Aug 2008 15:56:04 +0200 From: Michael Heerdegen To: emacs-pretest-bug@gnu.org Subject: Elisp: lexical-let and cyclic structures Reply-to: michael_heerdegen@web.de Date: Wed, 20 Aug 2008 15:57:16 +0200 Message-Id: <1219240636.0@debian> Sender: Michael_Heerdegen@web.de X-Sender: michael_heerdegen@web.de X-Provags-ID: V01U2FsdGVkX18g64pMWVCWpWPcfiYzXqe+V4YfbnpJ//DeWIAe /e+Nqnx7i/AtPVV3/EnlKYTDXPkVw0RzjNCDYrUGJzWAJpV9ql i/BOocuL7wVCdrUjEEvg== X-detected-kernel: by monty-python.gnu.org: Linux 2.4-2.6 When using the reader constructs `#N=' and `#N#' for cyclic structures, lexical-let sometimes produces errors which don't occur with let. Example: Eval the following: (defun f (start) (lexical-let (start start) ;; return a closure #1=(lambda (x) (if (= x start) x (+ x (#1# (1- x))))))) Then evaluating f ends with an error: (f 3) "Variable binding depth exceeds max-specpdl-size" The problem also occurs without lambdas. Examples: (let () '#1=(#1#)) ;; ==> (#0) (lexical-let () '#1=(#1#)) ;; Error (let ((x '#1=(#1#))) (lexical-let () x)) ;; ==> (#0) `#1=(#1#) ;; Error ------------=_1310233922-24052-1--