Next: , Previous: Weak references, Up: System features


4.1.11 Type annotations

Scheme48 allows optional type annotations with the loophole special form from the loopholes structure.

— syntax: loophole type expression –> values

This is exactly equivalent in semantics to expression, except the static type analyzer is informed that the whole expression has the type type. For details on the form of type, see Static type system.

Type annotations can be used for several different purposes:

To see an example of the second use, see rts/jar-defrecord.scm in Scheme48's source tree.

Note: Type annotations do not damage the safety of Scheme's type system. They affect only the static type analyzer, which does not change run-time object representations; it only checks type soundness of code and generates warnings for programs that would cause run-time type errors.