Closed chharvey closed 3 years ago
Add typings to variable declarations.
DeclarationVariable ::= "let" "unfixed"? IDENTIFIER ":" Type "=" Expression ";";
Example:
let my_var: int = 42;
Declares the my_var with type int (for Integer).
my_var
int
The following type units may be used:
null
bool
float
obj
Type expressions are syntax productions that combine types using operators.
‹T›!
‹T› | null
‹T› & ‹U›
‹T›
‹U›
‹T› | ‹U›
‹T› & (‹U› | ‹V›)
(‹T› and ‹U› are metavariables for syntactically allowed type expressions.)
Add typings to variable declarations.
Example:
Declares the
my_var
with typeint
(for Integer).The following type units may be used:
null
valuebool
keyword, which denotes “any Boolean value”int
keyword, which denotes “any Integer value”float
keyword, which denotes “any Float value”obj
keyword, which denotes “any value whatsoever (including thenull
value)”Type expressions are syntax productions that combine types using operators.
‹T›!
is shorthand for the type union‹T› | null
.‹T› & ‹U›
is a type intersection, which denotes values of both types‹T›
and‹U›
.‹T› | ‹U›
is a type union, which denotes values of either type‹T›
or‹U›
.‹T› & (‹U› | ‹V›)
.(
‹T›
and‹U›
are metavariables for syntactically allowed type expressions.)