Created
August 27, 2010 04:16
-
-
Save valvallow/552782 to your computer and use it in GitHub Desktop.
PAIP, gauche, scheme,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; debug tools | |
;; PAIP(実用 Common Lisp) - P.116 - 4.10 | |
(define-module liv.debugs | |
(use srfi-1) | |
(use gauche.parameter) | |
(export-all)) | |
(select-module liv.debugs) | |
(define *dbg-ids* (make-parameter '())) | |
;; (define (dbg id format-string . args) | |
;; (when (member id (*dbg-ids*)) | |
;; (let1 port (current-error-port) | |
;; (newline port) | |
;; (apply format port format-string args)))) | |
(define dbg (cut debug-indent <> 0 <> <...>)) | |
(define (debug . ids) | |
(*dbg-ids* (lset-union eq? ids (*dbg-ids*)))) | |
(define (undebug . ids) | |
(*dbg-ids* (if (null? ids) | |
'() | |
(lset-difference eq? (*dbg-ids*) ids)))) | |
(define (debug-indent id indent format-string . args) | |
(when (member id (*dbg-ids*)) | |
(let1 port (current-error-port) | |
(newline port) | |
;; (dotimes (i indent (display " " port))) | |
(display (apply string-append (make-list indent " ")) port) | |
(apply format port format-string args)))) | |
(provide "liv/debugs") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment