improved ASSERT interface

This commit is contained in:
Rolf-Thomas Happe 2003-03-19 21:42:21 +00:00
parent 85539d1d46
commit 9ef33b4651
2 changed files with 18 additions and 22 deletions

View File

@ -32,16 +32,15 @@ structure KRIMS -- Odds and Ends
The structure KRIMS gathers miscellaneous tiny utilities mainly for use The structure KRIMS gathers miscellaneous tiny utilities mainly for use
of other sunterlib projects. of other sunterlib projects.
(assert [id] exp) SYNTAX (assert exp x0 ...) SYNTAX
The usual ASSERT macro with an optional ID tag: Signal an error and Signal an error if EXP is false, reporting both the failed assertion EXP
complain if EXP evaluates to false. The error message contains the (literally) and the values of X0 ... Don't evaluate X0 ... if EXP holds
value of ID (if supplied) and the expression EXP. [ ASSERT being a true.
macro, we can change it to the trivial form that doesn't evaluate its
arguments and recompile before selling our stuff ... ]
* *
(receive/name loop formals exp form0 ...) SYNTAX (receive/name loop formals exp form0 ...) SYNTAX
RECEIVE/NAME is a multi-values analogue of named LET (but much less RECEIVE/NAME is a multi-values analogue of named LET (but much less

View File

@ -4,11 +4,8 @@
(define-syntax assert (define-syntax assert
(syntax-rules () (syntax-rules ()
((assert ?x) ((assert ?x ?y0 ...)
(if (not ?x) (error "Assertion failed" '?x))) (if (not ?x) (error "Assertion failed" '?x ?y0 ...))) ))
((assert ?tag ?x)
(if (not ?x) (error (format #f "~a -- assertion failed" ?tag)
'?x)))))
;; RECEIVE/NAME is a multiple values analogue of named LET. ;; RECEIVE/NAME is a multiple values analogue of named LET.