[Oberon] Clarifying type compatibility in Oberon-07

August Karlstrom fusionfile at gmail.com
Thu Oct 5 11:09:38 CEST 2017


On 2017-10-05 10:20, Jörg wrote:
> 9.1.4 is indeed an interesting one
> 
> Here an example to demonstrate what 9.1.4 says:
> 
> VAR global: ARRAY 20 OF INTEGER;
> 
> PROCEDURE A (open: ARRAY OF INTEGER)
>    VAR local: ARRAY 10 OF INTEGER
>    BEGIN
>      local := open (* this is mentioned in 9.1.4 *)
>    END A;
> 
> BEGIN
>    A(global)   (* this is covered by Array rule 2 *)
> END.
> 
> Two remarks:
> Indeed 9.1.4 is not covered by any of the existing rules of Appendix A.

That's why it needs to be added (which I did in the first post of this 
thread).

> On the other hand, I can’t find where your example of a := b is mentioned in the Oberon-07 report (independent of the fact that the compiler allows it..)

Neither can I. However, sometimes a rule is implied by some other rule. 
That's why I ask for help here. In fact, also pointers are structurally 
equivalent in PO2003 in the sense that the compiler (if I'm not 
mistaken) accepts a module like this:

	MODULE M;
	
		TYPE
			T = RECORD END;
	
		VAR
			p: POINTER TO T;
			q: POINTER TO T;
			
	BEGIN
		p := q
	END M.

This seems to be the definition of *same type* in PO2003:

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 array types whose element types and lengths are the 
same, or
5. Ta and Tb are pointer types whose pointer base types are the same, or
6. Ta and Tb are procedure types whose formal parameter lists match.

This means that name equivalence is only used for records. The question 
is if 4, 5, and 6 are "language extensions".


-- August


More information about the Oberon mailing list