Variable Declarations

Variables

There are two forms of variable declarations in Tiger: the short one and the long one.

In the short form, only the name of the variable and the initial value of the variable are specified, the variable type is inferred.

let
  var foo := 1  /* foo is typed as an integer */
in
  ...
end

In the long form, the type of the variable is specified. Since one cannot infer a record type for nil, the long form is mandated when declaring a variable initialized to nil.

let
  type foo = {foo : int}
  var bar : foo := nil       /* Correct.   */
  var baz       := nil       /* Incorrect. */
in
  ...
end