guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aborting debugger prompt


From: Ian Price
Subject: Re: Aborting debugger prompt
Date: Fri, 14 Oct 2011 01:49:11 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Tobias Gerdin <address@hidden> writes:

> When an error occurs and you are running under the REPL you are
> dropped into the debugger ("Entering a new prompt. .."). This is
> useful. But I am wondering if it is not possible to abort this prompt
> with a user-defined value? That is, to get hold of the continuation
> and applying it to some value so that the execution can continue from
> the point of the error.

I agree, guile already supports R6RS exceptions, which may be
continued if called with raise-continuable, so it would be nice to be
able to use it at the debugger. The obvious thing to do would be to
extend the ,continue meta command so that we could do, say


scheme@(guile−user)> (+ 88 (raise-continuable 10))
<unnamed port>:43:6: In procedure #<procedure 8affc40 at <current input>:43:0 
()>:
<unnamed port>:43:6: ERROR: R6RS exception: `10'

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile−user) [1]> ,continue 10
$5 = 98


In the likely event that this undesirable to the guile implementers. A
somewhat less satisfying solution is to roll it yourself with
continuations, something like


;; WARNING: quick hack, may not perform as advertised
(use-modules (ice-9 control))

(define k #f)

(define (bad val)
  (shift c (begin (set! k c) (throw 'resumable val))))

(define (resume val)
  (k val))

scheme@(guile−user)> (+ 10 (bad 9))
<unnamed port>:154:2: In procedure #<procedure 93b9a10 at <current input>:154:2 
(cont)>:
<unnamed port>:154:2: Throw to key `resumable' with args `(9)'.

Entering a new prompt.  Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile−user) [1]> ,q
scheme@(guile−user)> (resume 8)
$7 = 18

-- 
Ian Price

"Programming is like pinball. The reward for doing it well is
the opportunity to do it again" - from "The Wizardy Compiled"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]