1 Exception utilities
2 Number utilities
3 String utilities
4 Symbol utilities
5 SRFI19 time utilities
6 List
7 PLT 4x hash utilities
8 PLT 3x hash utilities
9 Contract utilities
10 File and path utilities
11 Parameter utilities
12 Syntax utilities
13 Generators
14 Generators (short names)
15 Pipelines
16 Write-through cache
17 Yieldable procedures
18 Debugging tools
19 Profiling tools
20 Logging tools
On this page:
debug-enabled?
current-debug-printer
debug
debug*
define-debug
let-debug
let*-debug
letrec-debug
Version: 3.99.0.23

 

18 Debugging tools

 (require (planet untyped/unlib/debug))

Utilities for printing the runtime values of variables for debugging purposes, with minimal disruption to code structure.

(debug-enabled?)  boolean?

(debug-enabled? val)  void?

  val : boolean?

Boolean parameter for enabling or disabling the printing of debugging information. Defaults to #t.

(current-debug-printer)  (-> string? any void?)

(current-debug-printer proc)  void?

  proc : (-> string? any void?)

Parameter controlling the formatting of printed debugging information. Value must be a procedure that takes a message and a value and returns void. The default value prints the message and a colon on one line and pretty-prints the value (slightly indented) on subsequent lines.

(debug val)  any

  val : any

Prints val and returns it transparently.

Examples:

  > (length (debug "message" (make-list 5 (iota 10))))

  message:

    ((0 1 2 3 4 5 6 7 8 9)

     (0 1 2 3 4 5 6 7 8 9)

     (0 1 2 3 4 5 6 7 8 9)

     (0 1 2 3 4 5 6 7 8 9)

     (0 1 2 3 4 5 6 7 8 9))

  5

(debug* proc arg ...)  any

  proc : procedure?

  arg : any

Applies proc to args and prints and returns the return value transparently.

Examples:

  > (debug* "message" * 2 2)

  message:

    4

  4

(define-debug id expr)

Expands to a define form that prints the value of id as a side effect.

Examples:

  > (define-debug test-data

      (+ 1 2 3))

  test-data:

    6

(let-debug ([id expr] ...) expr ...)

Expands to a let form that prints the value of each id as it is assigned.

Examples:

  > (let-debug ([a (+ 1 2)]

                [b (+ 3 4)])

       b)

  a:

    3

  b:

    7

  7

(let*-debug ([id expr] ...) expr ...)

Expands to a let* form that prints the value of each id as it is assigned.

Examples:

  > (let*-debug ([a (+ 1 2)]

                 [b (* b b)])

       b)

  a:

    3

  reference to undefined identifier: b

(letrec-debug ([id expr] ...) expr ...)

Expands to a letrec form that prints the value of each id as it is assigned.

Examples:

  > (let-debug ([a (+ 1 2)]

                [b (* b b)])

       (append a b))

  a:

    3

  reference to undefined identifier: b