add debugging macro to unstable

svn: r17534
This commit is contained in:
Sam Tobin-Hochstadt 2010-01-07 17:09:35 +00:00
parent b71b196764
commit e9165339b8
2 changed files with 43 additions and 0 deletions

View 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))]))

View 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)
]
}