all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dan Davison <davison@stats.ox.ac.uk>
To: help-gnu-emacs@gnu.org
Subject: flet not undone on lisp nesting error
Date: Sat, 27 Feb 2010 15:22:02 -0500	[thread overview]
Message-ID: <87mxyuv385.fsf@stats.ox.ac.uk> (raw)

If I trigger a lisp nesting error with an infinite recursion inside a
let and an flet binding, then the effects of the flet are not undone,
resulting in a change of binding at the top-level. (Code below; the
effects of the let are undone).

However, if I trigger a "normal" error with (error) then both are
undone. Is this peculiar to a circular lisp nesting error, or are there
other classes of error upon which flet will not be undone? What is the
idiomatic way to protect against this (other than not having infinite
recursions in my code)? Do I have to keep copies of the original values
for use in an unwind-protect?

Dan

--8<---------------cut here---------------start------------->8---
(defun g () 'g-orig)
(setq a 'a-orig)

(defun h ()
  (let ((a 'a-new))
    (flet ((g () 'g-new))
      (h))))
(h)   ;; <-- Lisp nesting exceeds `max-lisp-eval-depth'
(g)   ;; 'g-new ! 
a     ;; a-orig 

(defun g () 'g-orig)
(setq a 'a-orig)
(defun f ()
  (let ((a 'a-new))
    (flet ((g () 'g-new))
      (error "Error!"))))

(f)
(g) ;; <-- 'g-orig
a   ;; <-- 'a-orig
--8<---------------cut here---------------end--------------->8---




             reply	other threads:[~2010-02-27 20:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-27 20:22 Dan Davison [this message]
     [not found] <mailman.2053.1267396226.14305.help-gnu-emacs@gnu.org>
2010-03-01  1:01 ` flet not undone on lisp nesting error Stefan Monnier
2010-03-01  1:03 ` Pascal J. Bourguignon

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=87mxyuv385.fsf@stats.ox.ac.uk \
    --to=davison@stats.ox.ac.uk \
    --cc=help-gnu-emacs@gnu.org \
    /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.