[Oberon] Clarifying type compatibility in Oberon-07
August Karlstrom
fusionfile at gmail.com
Thu Oct 5 14:12:56 CEST 2017
On 2017-10-05 12:52, Jörg wrote:
>> So this is your understanding of *same type* in Oberon-07:
>>
>> Two variables a and b with types Ta and Tb are of the same type if
>> 1. Ta and Tb are both denoted by the same type identifier, or
>> 2. Ta is declared to equal Tb in a type declaration of the form Ta = Tb, or
>> 3. a and b appear in the same identifier list in a variable, record field, or formal parameter declaration and are not open arrays, or
>> 4. Ta and Tb are pointer types whose pointer base types are the same, or
>> 5. Ta and Tb are procedure types whose formal parameter lists match.
>
> No. My understanding of "same type" is as in Oberon-2:
Then the list of exceptions in section 9.1 in the Oberon-07 report is
incomplete (for instance when it comes to assignment of procedure
constants to procedure variables).
> Assignment rule 1 uses „same type". The things NOT covered by „same type“ are mentioned explicitly with own assignment rules.
OK, new attempt:
Same type
(unchanged from Obeorn-2)
Assignment compatible
An expression e of type Te is assignment compatible with a variable v of
type Tv if one of the following conditions hold:
1. Te and Tv are the same type;
*2. Te and Tv are different integer types;
3. Te and Tv are record types and Te is an extension of Tv and the
dynamic type of v is Tv ;
4. Te and Tv are pointer types and Te is an extension of Tv;
5. Tv is a pointer or a procedure type and e is NIL;
6. Tv is ARRAY n OF CHAR, e is a string constant with m characters, and
m < n;
*7. Te and Tv are procedure types whose formal parameter lists match;
*8. Tv is CHAR and e is a single-character string constant;
*9. Tv is an array type and Te is an open array type with the same
element types as Tv.
Here paragraph 2 and 7 have been modified and 8 and 9 has been added.
"Integer types" are assumed to be defined as BYTE and INTEGER.
Does it make sense?
-- August
More information about the Oberon
mailing list