chickadee » moremacros » checked-guard

(checked-guard GETTER-NAME TYPENAME [BODY...])syntax

Constructs a variable or parameter guard procedure that uses a type check procedure to verify the submitted value is returned.

TYPENAME is an identifier and check-TYPENAME is a (procedure ((or #f symbol) * #!optional (or symbol string)) *). See check-errors for a suite of these procedures.

GETTER-NAME is an identifier and the name of a procedure _ *.

BODY is zero or more expressions that are performed after a successful typecheck with obj bound to the new parameter value. Note that since the guard is invoked by a variable or parameter during initialization, so will be the body code.

(import (type-checks-numbers integer))

(checked-guard some-var natural-integer)