all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: 748@emacsbugs.donarmstrong.com
Subject: bug#748: Elisp: lexical-let and cyclic structures
Date: Wed, 20 Aug 2008 21:12:22 -0400	[thread overview]
Message-ID: <jwvod3ngorc.fsf-monnier+emacsbugreports@gnu.org> (raw)
In-Reply-To: <1219240636.0@debian> (Michael Heerdegen's message of "Wed, 20 Aug 2008 15:57:16 +0200")

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






  reply	other threads:[~2008-08-21  1:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-20 13:57 bug#748: Elisp: lexical-let and cyclic structures Michael Heerdegen
2008-08-21  1:12 ` Stefan Monnier [this message]
2011-07-09 17:51   ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvod3ngorc.fsf-monnier+emacsbugreports@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=748@emacsbugs.donarmstrong.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.