Contents | Prev | Next | Index
Variable declarations serve to introduce and associate them with a unique identifier and a data type.
var_decl ::= var_ident_list : type var_ident_list ::= var_ident_list , var_ident ::= var_ident var_ident ::= <identifier> ::= <identifier> [ <string> ] ::= <identifier> java_name |
In this compiler, if the generated Java identifier is to be different from the variable identifier, that Java identifier may be specified after the Modula-2 identifier, either as a string or as a JAVA NAME directive.
Record and pointer variables have both a static type and a dynamic type (the type they assume at run time). For pointers and variable parameters of record type, the dynamic type may be an extension of their static type. The static type determines which fields of a record are accessable. The dynamic type is used to call type-bound procedures (also known as methods in Java).
Examples of variable declarations (see also section about type declarations):
i,j,k : INTEGER
x,y : REAL
p, q : BOOLEAN
s : BITSET
F : Function
a : ARRAY [1..100] OF REAL
w : ARRAY [1..16] OF RECORD
name : ARRAY [0..31] OF CHAR;
count : INTEGER;
END
t,c : Tree
Contents | Prev | Next | Index
Canterbury Modula-2 for Java (Last documentation update
Feb 8, 2000)
Copyright © 1998 Mill Hill &
Canterbury Corporation, Ltd. All rights reserved
Please send any comments or corrections to
mhc@webcom.com