: >
: >: MODULE test;
: >: TYPE
: >: int = RECORD i : INTEGER END;
: >: meters = POINTER TO int;
: >: feet = POINTER TO int;
: >: VAR
: >: m : meters;
: >: f : feet;
: >: BEGIN
: >: m := f;
: >: END test.
: >
: >: Yet, on the three implementations I tried it (MacOberon, MacOberon
: >: Lite, and SPARCOberon), it does not produce a type compatibility
: >: error. Why?
: >
: >It does the same thing on POWEROberon.
: We will have to wait for the ETH people to give an official answer,
Agreed. It is too bad that there is no one on duty on the weekends
to handle crisis situations -:)
: First of all, let us take a look at what is 'same type'.
: I am only interested in #2.
: Ta is declared to equal Tb in a type declaration of the form Ta = Tb
: In this case, my interpretation as: a = b; c = b; then a = c. This may not
: be entirely true, but it makes sense.
No. This is making things up.
: Assignment compatibility states:
: An expression e of type Te is assignment compatible witha variable v of
: type Tv is one of the following conditions holds (In C-speak, e is an
: rvalue, and v is an lvalue)
: 1) Te and Tv are the same type. [I think they are]
** I don't think they are **
: 4) Te and Tv are pointer types and Te iss an extension of Tv.
: I think #4 shows WHY they are allowed. The pointer types are compatible.
I agree that #4 shows WHY they are allowed. Te is an extension of Tv.
see Type extension rules.
If Pa = POINTER TO Ta and Pb = POINTER TO Tb, Pb is an extension of Pa
( Pa is a base type of Pb ) if Tb is an extension of Ta.
Without reading the rules I would have said that Tb is not an extension
of Ta, but that it is the same type as Ta. This is not the case :
Tb is an extension of Ta ( Ta is a base type of Tb ) if
1. Ta and Tb are the same types,
---------------------------------
BTW, another rule could work for some (broken) compilers.
see Assignment compatible rule 5.
Tv is a pointer or a procedure type and e is NIL.
If the compiler sets pointers to NIL, and applies data
flow before type-rules then m := f; becomes m := NIL;
--------------------------------
Whitney