Previous: , Up: overview   [Contents][Index]


1.4 Typed lexical variables

A typed lexical variable, shortly typed variable, is a bound syntactic identifier whose syntactic binding’s descriptor contains both informations about a lexical variable and its type annotation. Typed variables are created by the built–in binding syntaxes lambda, define, let, letrec, let-values, et cetera.

An example of typed binding creation follows:

#!vicare
(program (demo)
  (options typed-language)
  (import (vicare)
  (define {O <fixnum>}
    123))

the syntactic identifier O represents a typed variable with type annotation <fixnum>.

At the time the typed variable’s syntactic binding is established: the type annotation must hold only already bound type identifiers. So the following program (where ‘---’ represents an unspecified form) is correct because <duo> is bound before O:

#!vicare
(program (demo)
  (options typed-language)
  (import (vicare))
  (define-record-type <duo>
    (fields one two))
  (define {O <duo>}
    ---))

the follow program is not correct:

#!vicare
(program (demo)
  (options typed-language)
  (import (vicare))
  (define {O <duo>}
    ---)
  (define-record-type <duo>
    (fields one two)))

and will cause an expand–time syntax violation.