Vikari Language Documentation


Available since:  v0.4.0.

Variable Declarations

In Vikari, a variable can be declared using a valid Vikari variable identifier followed by an optional type label and initializer expression after a left assignment operator. After a variable has been declared, it can then be used in further expressions and statements to reassign or use its value as desired.

All variables have both a declared type and an assigned type. The declared type is AtonementCrystal if no type label is included. Otherwise the declared type matches the type of the type label. Meanwhile the assigned type is matched against the concrete type of the result of the last assignment expression that assigned a value to the variable. Type checking is done against the assigned type to ensure it is valid to assign that type to the declared type of the variable.

Examples

The following demonstrates each form of a variable declaration.

~:The simplest form of a variable declaration.:~
foo

~:With type label.:~
foo:AtonementCrystal

~:With initializer expression.:~
foo << 3

~:With type label and initializer expression.:~
foo:Integer << 3