aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Court`es2006-07-19 12:51:24 +0000
committerLudovic Court`es2006-07-19 12:51:24 +0000
commiteabbe664c072a1633407017061f9e46bc1265249 (patch)
tree74688dfd441aefaec949be53778c15319c6072ba
parent11c3af991c91a6c5cb571bfd38ed71ddc0a05b10 (diff)
downloadskribilo-eabbe664c072a1633407017061f9e46bc1265249.tar.gz
skribilo-eabbe664c072a1633407017061f9e46bc1265249.tar.lz
skribilo-eabbe664c072a1633407017061f9e46bc1265249.zip
Turned `with-debug' into a more self-sufficient macro.
* src/guile/skribilo/debug.scm (%with-debug): Replaced by `%do-with-debug'. (with-debug): Made into a macro. git-archimport-id: lcourtes@laas.fr--2005-libre/skribilo--devo--1.2--patch-15
-rw-r--r--src/guile/skribilo/debug.scm40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/guile/skribilo/debug.scm b/src/guile/skribilo/debug.scm
index a06067c..4b5f543 100644
--- a/src/guile/skribilo/debug.scm
+++ b/src/guile/skribilo/debug.scm
@@ -128,28 +128,28 @@
;;;
;;; %with-debug
;;;
-(define-public (%with-debug lvl lbl thunk)
- (if (or (and (number? lvl) (>= (*debug*) lvl))
- (and (symbol? lbl)
- (memq lbl (*watched-symbols*))))
- (parameterize ((*margin-level* lvl)
- (*debug-item?* #t))
- (display (*debug-margin*) (*debug-port*))
- (display (if (= (*debug-depth*) 0)
- (debug-color (*debug-depth*) "+ " lbl)
- (debug-color (*debug-depth*) "--+ " lbl))
- (*debug-port*))
- (newline (*debug-port*))
- (%with-debug-margin (debug-color (*debug-depth*) " |")
- thunk))
- (thunk)))
+(define-public (%do-with-debug lvl lbl thunk)
+ (parameterize ((*margin-level* lvl)
+ (*debug-item?* #t))
+ (display (*debug-margin*) (*debug-port*))
+ (display (if (= (*debug-depth*) 0)
+ (debug-color (*debug-depth*) "+ " lbl)
+ (debug-color (*debug-depth*) "--+ " lbl))
+ (*debug-port*))
+ (newline (*debug-port*))
+ (%with-debug-margin (debug-color (*debug-depth*) " |")
+ thunk)))
(define-macro (with-debug level label . body)
- `(%with-debug ,level ,label (lambda () ,@body)))
-
-;;(define-macro (with-debug level label . body)
-;; `(begin ,@body))
-
+ ;; We have this as a macro in order to avoid procedure calls in the
+ ;; non-debugging case. Unfortunately, the macro below duplicates BODY,
+ ;; which has a negative impact on memory usage and startup time (XXX).
+ (if (number? level)
+ `(if (or (>= (*debug*) ,level)
+ (memq ,label (*watched-symbols*)))
+ (%do-with-debug ,level ,label (lambda () ,@body))
+ (begin ,@body))
+ (error "with-debug: syntax error")))
; Example: