Scheme Programmer's Manual
assert - raise an assertion violation if an expression is false
(import (rnrs)) ;R6RS
(import (rnrs base)) ;R6RS
form is evaluated by evaluating
returns #f, an exception with condition types &assertion and &message
is raised. The message provided in the condition object is
- Ikarus Scheme
returns a true value, that value is returned
(define (integer-add x y)
(assert (and (integer? x) (integer? y)))
(+ x y))
(integer-add 1 2)
(integer-add 1 2.1)
=> raises &assertion and &message
Applications can use this form to guard against invalid uses of
procedures. It is often more convenient than manual use of
Implementations can exploit the fact that
is syntax to provide as much information as possible about the
location of the assertion failure.
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
The wrong number of arguments was passed or an argument was outside its domain.
- &syntax (R6RS)
More or fewer than one expression was passed.
The assert macro is new in R6RS, but has a long history in programming.
This page is part of the
It includes materials from the RnRS documents.
More information can be found at
The implementation in psyntax from the r6rs-libraries project is buggy
and does not return the true value. This bug has spread into some
Return to Main Contents
- IMPLEMENTATION NOTES
- RETURN VALUES
- APPLICATION USAGE
- SEE ALSO