Next: overview type ids, Previous: overview philosophy, Up: overview [Contents][Index]
Typed language extensions are off by default. To enable the
extensions we have to use the typed-language
option as follows:
(library (demo) (options typed-language) (export) (import (vicare)) ---)
(program (demo) (options typed-language) (import (vicare)) ---)
we usually want to import the library (vicare)
to use the
extended syntaxes that recognise type definitions and annotations.
We can use the function typed-language-enabled?
to enable the
typed language at the REPL (see (vicare-scheme)typed-language-enabled?).
An additional option is available for both programs and libraries:
strict-type-checking
. It enables expand–time warnings about
non–exact matching between values and the typed variables they are
assigned to.
Under the typed language, the types of variables and values are matched as with the following forms:
(import (prefix (vicare expander) xp::)) (xp::type-annotation-matching <number> <fixnum>) ⇒ exact-match (xp::type-annotation-matching <fixnum> <number>) ⇒ possible-match
that is:
<fixnum>
exactly matches an expected argument
of type <number>
. The operand validation is successful at
expand–time.
<number>
is compatible with an expected
argument of type <fixnum>
. The operand validation is successful
at expand–time, but further validation at run–time is required.
When the option strict-type-checking
is used: a warning is raised
when a possible match is detected. For example, the following
let
syntax use will raise a warning because the right–hand
side expression returns a <integer>
, while the syntactic binding
for O
expects a <fixnum>
:
(let (({O <fixnum>} (cast-signature (<integer>) (read)))) ---)
When examining the raised warnings we must remember that some binding syntaxes expand into uses of other binding syntaxes; for some built–in syntaxes of this type:
Next: overview type ids, Previous: overview philosophy, Up: overview [Contents][Index]