Scheme defines a number of standard type testing predicates.
For example (vector? x) is #t if and only if
x is a vector.
Kawa generalizes this to arbitrary type names:
If T is a type-name (that is in scope at compile-time),
then is a one-argument function that returns
T?#t if the argument is an instance of the type ,
and T#f otherwise:
(gnu.lists.FVector? #(123)) ⇒ #t (let ((iarr (int[] 10))) (int[]? iarr)) ⇒ #t
To convert (coerce) the result of an expression value to a
type T use the syntax: (->.
T value)
(->float 12) ⇒ 12.0f0
In general:
(T?x) ⇒ (instance?xT) (->Tx) ⇒ (asTx)
Procedure: instance? value type
Returns
#tiffvalueis an instance of typetype. (Undefined iftypeis a primitive type, such asint.)
Converts or coerces
valueto a value of typetype. Throws an exception if that cannot be done. Not supported fortypeto be a primitive type such asint.