本页描述了一些有趣的调试工具:Debugging Aids。
从短期实验我试过了,我想你可以使用pp
功能检查复合程序对象的源:
1 ]=> (define (sum-squares x y) (+ (* x x) (* y y)))
;Value: sum-squares
1 ]=> (sum-squares 3)
;The procedure #[compound-procedure 13 sum-squares]
;has been called with 1 argument
;it requires exactly 2 arguments.
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.
2 error> (pp #[compound-procedure 13 sum-squares])
(named-lambda (sum-squares x y)
(+ (* x x) (* y y)))
;Unspecified return value
2 error>
看来,你甚至可以得到的lambda
函数的源和编译功能:
1 ]=> (define (make-acc-gen n) (lambda (i) (set! n (+ n i)) n))
;Value: make-acc-gen
1 ]=> (pp (make-acc-gen 0))
(lambda (i)
(set! n (+ n i))
n)
;Unspecified return value
1 ]=> display
;Value 15: #[compiled-procedure 15 ("output" #x16) #x1a #x101b23bd2]
1 ]=> (pp #[compiled-procedure 15 ("output" #x16) #x1a #x101b23bd2])
(named-lambda (display object #!optional port environment)
(let ((port (optional-output-port port 'display)))
(unparse-object/top-level object port #f environment)
((%record-ref (%record-ref port 1) 14) port)))
;Unspecified return value
1 ]=>
在链接页面上还有一些其他有趣的反射工具。麻省理工学院计划也有一个bunch of stuff与环境作为一流的对象,可用于某些调试任务。希望有所帮助!
是的,这有助于很多 - 正是需要的! – limist 2012-01-12 17:40:58
甚至更短:(pp#@ 42),其中42是程序编号。 – limist 2012-01-12 18:35:58