GNU bug report logs - #748
Elisp: lexical-let and cyclic structures

Previous Next

Package: emacs;

Reported by: michael_heerdegen <at> web.de

Date: Wed, 20 Aug 2008 14:05:05 UTC

Severity: normal

Tags: wontfix

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 748 in the body.
You can then email your comments to 748 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#748; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to michael_heerdegen <at> web.de:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: emacs-pretest-bug <at> gnu.org
Subject: Elisp: lexical-let and cyclic structures
Date: Wed, 20 Aug 2008 15:57:16 +0200
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




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#748; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 748 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 748 <at> debbugs.gnu.org
Subject: Re: bug#748: Elisp: lexical-let and cyclic structures
Date: Wed, 20 Aug 2008 21:12:22 -0400
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




Tags added: wontfix Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Sat, 23 Aug 2008 19:15:06 GMT) Full text and rfc822 format available.

Reply sent to Glenn Morris <rgm <at> gnu.org>:
You have taken responsibility. (Sat, 09 Jul 2011 17:52:02 GMT) Full text and rfc822 format available.

Notification sent to michael_heerdegen <at> web.de:
bug acknowledged by developer. (Sat, 09 Jul 2011 17:52:02 GMT) Full text and rfc822 format available.

Message #17 received at 748-done <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: 748-done <at> debbugs.gnu.org
Subject: Re: bug#748: Elisp: lexical-let and cyclic structures
Date: Sat, 09 Jul 2011 13:51:43 -0400
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.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 07 Aug 2011 11:24:12 GMT) Full text and rfc822 format available.

This bug report was last modified 13 years and 317 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.