Re: Debugging REPL

"Daniel Sadilek" <[email protected]> Tue, 12 Jun 2007 14:33:36 +0200
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
I found a workaround:

(define-syntax debug
  (syntax-rules ()
    ((_ var ...)
     (begin
       (print "Debugging. Available lexical bindings: " '(var) ...)
       (putprop 'var (make-child-environment (interaction-environment)) var) ...
       (repl)
       (print "Debugging ended.")))))

This special syntactic form can be used like this:

(define (f x)
  (let ((sq (* x x)))
    (debug x sq)
    (+ sq sq)))

Does anyone know a better solution?

Btw, I use the SchemeScript IDE and really like the editing style that
is made possible with the above debug-form. You can put "(debug
some-vars)" inside a procedure and execute it (or some other procedure
that calls it). Then, with access to the local variables, you can
write your code inside the procedure -- right in place -- and evaluate
by pressing Ctrl+Enter. If finished, you exit the debug REPL.
I'm interested, what is you preferred "editing cycle"?

Best regards
Daniel Sadilek

On 6/12/07, Daniel Sadilek <[email protected]> wrote:
> Hello all,
>
> for debugging, I want to start a REPL inside a procedure so that the
> lexical bindings inside the procedure are available.
>
> For example, if anything goes wrong in this procedure:
>
> (define (f x)
>   (let ((sq (* x x)))
>     (+ sq sq)))
>
> I would like to be able to change it to
>
> (define (f x)
>   (let ((sq (* x x)))
>     (debug-repl)
>     (+ sq sq)))
>
> and run it again. A REPL should be started in which I can access x and
> sq. Is this somehow possible?
> I couldn't figure out how I can make the lexical bindings accessible.
> Somehow the current environment would need to be accessed, wouldn't
> it?
>
> Best regards
> Daniel Sadilek
>

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/