[Oberon] Type compatibility rules for Pointers

chris chris at gcjd.org
Mon Jun 15 22:07:18 CEST 2020


On Mon, 15 Jun 2020 21:42:39 +0200, Michael Schierl wrote:
> Are you equally confused when you replace POINTER TO R by ARRAY 42 OF
> BYTE or even by INTEGER?
> 
> i.e.
> 
> TYPE I1 = INTEGER; I2 = INTEGER;
>   A1 = ARRAY 42 OF BYTE;
>   A2 = ARRAY 42 OF BYTE;

Yes I am. In my understanding this breaks the longstanding tradition 
since the Modula days, that type compatibility is declared by name and 
not inferred by structure (Only exception are procedure types for 
obvious reasons and type extension).
 
> As I understand it, of all custom types only record types have identity.
> All other types are just aliases of what is on the other side of the
> equals sign. So it should not matter if you replace every occurrence of
> I1 by INTEGER or A1 by ARRAY 42 OF BYTE 

The declaration
 	I1 = INTEGER;
declares an alias and no new type. ARRAY 42 OF BYTE is a new type.

The Oberon-2 report for example gives the first formal definition of 
"same type" I know of and it clearly states in 1. that same types means 
same type identifier.

"Same types"
	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.

> I am not sure where I have this from (I can see that it is not actually
> defined in the Oberon 07 Report), perhaps this is just from experience
> from other programming languages.

Looks you are right about Oberon-07. The Oberon-07 report is very vague 
about this.

Greetings, chris


More information about the Oberon mailing list