6.6
12 Legacy Forms
The following forms are provided by Typed Racket for backwards
compatibility.
(lambda: formals . body)
|
|
formals | | = | | ([v : t] ...) | | | | | | ([v : t] ... v : t *) | | | | | | ([v : t] ... v : t ooo bound) |
|
A function of the formal arguments
v, where each formal
argument has the associated type. If a rest argument is present, then
it has type
(Listof t).
An alias for the same form using
lambda:.
A polymorphic function, abstracted over the type variables
a. The type variables a are bound in both the types
of the formal, and in any type expressions in the body.
(opt-lambda: formals . body)
|
|
formals | | = | | ([v : t] ... [v : t default] ...) | | | | | | ([v : t] ... [v : t default] ... v : t *) | | | | | | ([v : t] ... [v : t default] ... v : t ooo bound) |
|
A function with optional arguments.
A polymorphic function with optional arguments.
A polymorphic function of multiple arities.
(let: ([v : t e] ...) . body)
|
(let: loop : t0 ([v : t e] ...) . body) |
Local bindings, like
let, each with
associated types. In the second form,
t0 is the type of the
result of
loop (and thus the result of the entire
expression as well as the final
expression in
body).
Type annotations are optional.
(plet: (a ...) ([v : t e] ...) . body)
|
A polymorphic version of
let:, abstracted over the type variables
a. The type variables
a are bound in both the types
of the formal, and in any type expressions in the
body.
Does not support the looping form of let.
|
(let*: ([v : t e] ...) . body)
|
|
|
|
|
Type-annotated versions of
let/cc and
let/ec.
As with
let:, the type annotation is optional.
These forms define variables, with annotated types. The first form
defines
v with type
t and value
e. The second
form does the same, but allows the specification of type variables. The third
allows for polydotted variables. The fourth, fifth, and sixth forms define a
function
f with appropriate types. In most cases, use of
: is
preferred to use of
define:.
Examples:
An alias for for.
Aliases for the same iteration forms without a :.
Defines a polymorphic function.