From 1e922a11288b92d04067110a48e637d0182a0448 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Wed, 14 Sep 2016 23:41:57 -0400 Subject: [PATCH] Added mtrace debugging --- test-let-values.scm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test-let-values.scm b/test-let-values.scm index 5926a95c..91f20542 100644 --- a/test-let-values.scm +++ b/test-let-values.scm @@ -10,16 +10,32 @@ ; (call-with-values (lambda () expr) ; (lambda params (let*-values rest . body)))))) +;; From http://okmij.org/ftp/Scheme/macros.html +(define-syntax mtrace + (syntax-rules () + ((mtrace x) + (begin + (display "Trace: ") (write 'x) (newline) + x)))) + (define-syntax my-let-values (syntax-rules () ((my-let-values ("step") (binds ...) bind expr maps () () . body) + (mtrace (let*-values (binds ... (bind expr)) (let maps . body))) + ) ((my-let-values ("step") (binds ...) bind old-expr maps () ((params expr) . rest) . body) + (mtrace (my-let-values ("step") (binds ... (bind old-expr)) () expr maps params rest . body)) + ) ((my-let-values ("step") binds (bind ...) expr (maps ...) (x . y) rest . body) + (mtrace (my-let-values ("step") binds (bind ... tmp) expr (maps ... (x tmp)) y rest . body)) + ) ((my-let-values ("step") binds (bind ...) expr (maps ...) x rest . body) + (mtrace (my-let-values ("step") binds (bind ... . tmp) expr (maps ... (x tmp)) () rest . body)) + ) ; ((my-let-values ((params expr) . rest) . body) ; (my-let-values ("step") () () expr () params rest . body)) ))