add debugging macro to unstable
svn: r17534
This commit is contained in:
parent
b71b196764
commit
e9165339b8
18
collects/unstable/debug.ss
Normal file
18
collects/unstable/debug.ss
Normal file
|
@ -0,0 +1,18 @@
|
|||
#lang scheme/base
|
||||
|
||||
(provide debug)
|
||||
|
||||
;; printf debugging convenience
|
||||
(define-syntax debug
|
||||
(syntax-rules ()
|
||||
[(_ (f . args))
|
||||
(begin (printf "starting ~a~n" 'f)
|
||||
(let ([l (list . args)])
|
||||
(printf "arguments are:~n")
|
||||
(for/list ([arg 'args]
|
||||
[val l])
|
||||
(printf "\t~a: ~a~n" arg val))
|
||||
(let ([e (apply f l)])
|
||||
(printf "result was ~a~n" e)
|
||||
e)))]
|
||||
[(_ f . args) (debug (f . args))]))
|
25
collects/unstable/scribblings/debug.scrbl
Normal file
25
collects/unstable/scribblings/debug.scrbl
Normal file
|
@ -0,0 +1,25 @@
|
|||
#lang scribble/doc
|
||||
@(require scribble/base
|
||||
scribble/manual scribble/eval
|
||||
"utils.ss"
|
||||
(for-label unstable/debug
|
||||
scheme/serialize
|
||||
scheme/contract
|
||||
scheme/base))
|
||||
|
||||
@title[#:tag "debug"]{Debugging}
|
||||
@(define the-eval (make-base-eval))
|
||||
@(the-eval '(require unstable/debug))
|
||||
|
||||
@defmodule[unstable/debug]
|
||||
|
||||
@unstable-header[]
|
||||
|
||||
@defform*[[(debug (f args ...))
|
||||
(debug f args ...)]]{
|
||||
Produce debugging output for the application of @scheme[f], including the values of @scheme[args].
|
||||
@examples[#:eval the-eval
|
||||
(debug (+ 3 4 (* 5 6)))
|
||||
(debug + 1 2 3)
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user