1 #lang debug
2 debug-repl


source code:

A racket lang-extension for debugging, based on sugar/debug.

1 #lang debug

 #lang debug package: debug
A lang-extension (like at-exp) that allows for quick debugging shorthands to a program written in any racket-based language that looks at the readtable.

To debug the value of an expression, simply put debug in front of the language at the top of the file (for instance #lang debug racket), and put #R, #RR or #RRR in front of the expression.

#lang debug racket
#R(+ 1 2)
;(+ 1 2) = 3

#lang debug racket
(+ 1 2 #R(* 3 4))
;(* 3 4) = 12

2 debug-repl

 (require debug/repl) package: debug



Creates a repl for debugging, which can access local variables in the context where it is used.

For example a (debug-repl) in a let form
(let ([x 1] [y 2])
Will be able to access the x and y local variables (if debugging information is enabled in DrRacket’s Choose Language window, or if the program was executed using racket -l errortrace -t myprogram.rkt).

It becomes much more useful in a function definition:
(define (f x y)
Then if you call (f 1 2), it will create a repl where x is 1 and y is 2.

In one of these repls, you can try evaluating different expressions. If you’re debugging a higher-order function for example, you can try out the functions it accepts or creates with multiple sets of arguments to see how they react.


(resume v ...)  any

  v : any/c
When called inside of a debug-repl, exits the repl. The call to debug-repl returns the arguments to resume.