[slime-devel] Re: SBCL restart-frame

Martin Simmons martin at lispworks.com
Fri Jan 20 12:24:11 UTC 2006


>>>>> On Fri, 20 Jan 2006 09:24:26 +0100 (CET), =?ISO-8859-2?Q?M=E9sz=E1ros_Levente?= <melevy at freemail.hu> said:
  levy> Delivered-To: slime-devel at common-lisp.net

  >> > Is it really this simple?
  >> 
  >> Not quite. The restarted function will be run in the wrong dynamic 
  >> environment. For example:
  >> 
  >> (declaim (optimize (debug 2)))
  >> 
  >> (defvar *a* 0)
  >> 
  >> (defun foo (a)
  >> (let ((*a* (1+ *a*)))
  >> (/ 2 a)))
  >> 
  >> (defun bar ()
  >> (print *a*)
  >> (foo 0))
  >> 
  >> When you call BAR, it'll print 0 and then call FOO, which will signal 
  >> an error. If we now restart BAR, the dynamic binding for *A* that FOO 
  >> established will still be visibile, and it'll print 1 instead.

  levy> On the other hand return from frame is already supported for SBCL in 
  levy> SLIME.

  levy> And if I got it right the above statement also means that return from 
  levy> frame works the same "somewhat bad" way. I mean returning from the 
  levy> frame of bar (in the debugger) the value of *a* will return 1 instead of 
  levy> 0.

  levy> Am I right?

Yes.  However, there are two environments here:

1) The environment used to compute arguments for the command.  Possibly this
   should be the environment of the frame, but it doesn't matter too much as
   long as the person debugging the code knows which environment is used.

2) The environment used to execute the command.  For "restart frame", this
   should be the original environment of the frame, otherwise functions like
   FOO will fail to perform correctly.  For "return from frame" it doesn't
   really matter which environment is used, becase no user code is executed.

__Martin



More information about the slime-devel mailing list