Next: iklib conditions procpre, Previous: iklib conditions failexpr, Up: iklib conditions [Index]
Remembering that every expression may return multiple values, let’s say we need code like this:
(receive (a b c) (expression) (unless (fixnum? a) (raise-exception)) (unless (symbol? b) (raise-exception)) (unless (string? c) (raise-exception)) ?body)
we might want to raise condition objects holding the index of the
returned value; for this we can use
&one-based-return-value-index
as follows:
(receive (a b c) (expression) (internal-body (define (%error sexp idx obj) (raise (make-assertion-violation) (make-message-condition "failed object validation") (make-failed-expression-condition sexp) (make-one-based-return-value-index-condition idx) (make-irritants (list obj)))) (unless (fixnum? a) (%error '(fixnum? a) 1 a)) (unless (symbol? b) (%error '(symbol? b) 2 b)) (unless (string? c) (%error '(string? c) 3 c))) ?body)
Condition type used to specify the one–based index of a return value in
a tuple of return values from an expression. It is derived from
&condition
. It has the following fields:
index
A positive fixnum representing the one–based index of a return value.
Build and return a new instance of
&one-based-return-value-index
.
Return #t
if obj is a condition object with component
&one-based-return-value-index
; otherwise return #f
.
Given a condition object of type
&one-based-return-value-index
return the index.