Go to the first, previous, next, last section, table of contents.

Variables

VAR <id> { "," <id> ... } [ ":" <type> ] [ ":=" <expr> ] ";"

Declaring variables in Modula-3 is much like Pascal, except that the type can be omitted if an initialization expression is provided. The initialization expression <expr> need not be constant. Here are some examples:

VAR
  x: INTEGER;
  s := "Hello";    (* type TEXT is implied *)
  chars := SET OF CHAR{'a'..'z'};    (* type SET OF CHAR is implied *)
  y, z := 0;       (* both y and z are INTEGER initialized to 0 *)


Go to the first, previous, next, last section, table of contents.