Today’s Topics
- 1. Procedures and Procedure Call
- 2. Array and Record Types
Todays Topics 1. Procedures and Procedure Call 2. Array and Record - - PowerPoint PPT Presentation
Todays Topics 1. Procedures and Procedure Call 2. Array and Record Types Procedure and Function Calls How to type check? - Example-driven, modelling, coding to the spec. Example: PROCEDURE foo (x : INTEGER; y : REAL) : BOOLEAN;
Comment on separation of type and scope Comment on separation of type and scope
delegate to ProcType delegate to ProcType
% Oberon A : ARRAY 256 OF INTEGER; B, C : ARRAY 256 OF INTEGER;
// C or C++ int A[256]; int B[256], C[256]; struct { char name[30]; int ssnum; } joe, fran; struct ssrec { char name[30]; int ssnum; } struct ssrec bill, dan; struct { char phonenumber[30]; int identifier; } one, two;
Same types (Oberon is “alias” or “name” equivalent, except for pointers) Two variables a and b with types Ta and Tb are of the same type if
a and T
and Tb
b are both denoted by the same type identifier, or
are both denoted by the same type identifier, or
Ta = Tb (e.g., TYPE TEMPERATURE = REAL;), or
record field, or formal parameter declaration and are not open arrays.
respectively and Ta' and Tb' are the same type. Equal types (note that equality is weaker than sameness) Two types Ta and Tb are equal if
match.
E.g., ARRAY OF INTEGER Only appear in param decls E.g., ARRAY OF INTEGER Only appear in param decls
spec suggests creating methods sameType & equalType
do they go in?
spec suggests creating methods sameType & equalType
do they go in?
Assignment compatible (v := e) An expression e of type Te is assignment compatible with a variable v of type Tv if one of the following conditions hold:
e and
and T Tv
v are
are numeric numeric types and types and T Tv
v includes
includes T Te
e;
;
Array compatible (array parameter passing) An actual parameter a of type Ta is array compatible with a formal parameter f of type Tf if:
are array compatible, or