Next: args forms, Previous: args definitions, Up: args [Index]
The following bindings are exported by the library (vicare
arguments validation)
.
If arguments validation is enabled: expand to code that validates the ?arg expressions using to the ?validator clause, then evaluate the ?body forms; if arguments validation is disabled: just evaluate the ?body forms.
?who must be an identifier used as argument when building a
&who
condition object.
?validator must be one among:
define-argument-validation
macro.
(or false ?validator-id)
, where: or
is the
identifier exported by (vicare)
; false
is an identifier
whose expression is the symbol false
; ?validator-id must be
an identifier previously used as name of validation clause by the
define-argument-validation
macro.
When this form is used, the first clause argument is first tested alone:
the clause succeeds if the first argument is #f
; otherwise all the
clause arguments are handed to the validation claused selected by
?validator-id.
void
, exported by (vicare)
; this is a
special case for which no validation is generated: the arg values
are considered always valid; this is sometimes useful when using this
macro in the expansion of another macro.
NOTE In future a full logic expression may be possible as ?validator argument. At present only the special
or
case is supported, withfalse
as first operand.
Simple example:
(define-argument-validation (fixnum who obj) (fixnum? obj) (procedure-argument-violation who "expected fixnum as argument" obj)) (define-argument-validation (integer who obj) (integer? obj) (procedure-argument-violation who "expected integer as argument" obj)) (with-arguments-validation (who) ((fixnum X) (integer Y)) (do-this) (do-that))
multiple clauses are evaluated from first to last, so the above example is equivalent to:
(with-arguments-validation (who) ((fixnum X)) (with-arguments-validation (who) ((integer Y)) (do-this) (do-that)))
which is equivalent to something like:
(if (fixnum? X) (if (integer? X) (begin (do-this) (do-that)) (procedure-argument-violation who "expected integer as argument" obj)) (procedure-argument-violation who "expected fixnum as argument" obj))
Like with-arguments-validation
, but the validation is always
performed even when global arguments validation is disabled.
Next: args forms, Previous: args definitions, Up: args [Index]