Hello, please look at the following example: TYPE R = RECORD i : INTEGER END; P1 = POINTER TO R; P2 = POINTER TO R; PROCEDURE Test(); VAR p1 : P1; p2 : P2; BEGIN NEW(p1); NEW(p2); IF p1 IS P2 THEN (* true *) END; p1 := p2; END Test; The dynamic type test is not a surprise as the type tag refers to the same record descriptor although I think it's a bit counter intuitive. I am a bit confused that p1 := p2 compiles without errors. The Oberon-07 report says: "The type of the expression must be the same as that of the designator" and gives a list of 4 exceptions. Here only number 3 is of interest: "3. In the case of records, the type of the source must be an extension of the type of the destination." But in my understanding pointers are not records and P1 and P2 are different types. Any comments? Greeting, chris
Hello Chris, Am 15.06.2020 um 21:09 schrieb chris:
TYPE R = RECORD i : INTEGER END; P1 = POINTER TO R; P2 = POINTER TO R;
PROCEDURE Test(); VAR p1 : P1; p2 : P2; BEGIN NEW(p1); NEW(p2); IF p1 IS P2 THEN (* true *) END; p1 := p2; END Test;
The dynamic type test is not a surprise as the type tag refers to the same record descriptor although I think it's a bit counter intuitive.
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; You can assign variables of type I1 to variables of type I2 or variables of type INTEGER and vice versa. Same with the array types.
But in my understanding pointers are not records and P1 and P2 are different types.
Any comments?
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 (except that the Oberon-07 compiler does not like unnamed non-open arrays as procedure parameter types). Records behave differently, RECORD i: INTEGER END cannot be replaced by R as each record type has identity. 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. Regards, Michael
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
On Mon, Jun 15, 2020, at 10:07 PM, chris wrote:
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).
A small clarification: variables of procedure types are compatible by name. The exception for structural is the assignment of a procedure constant to a procedure variable (because procedures constant have an anonymous type). If I remember correct, it's the same in Modula-2. -- Diego Sardina
-----Original Message-----
From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of chris
Sent: Tuesday, 16 June 2020 5:37 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Type compatibility rules for Pointers
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.
There has been much debate about this in the past. Not all of the rules are explicitly spelt out in the Language Report. In the introduction to the Language Report Wirth says: ". What remains unsaid is mostly left so intentionally, either because it is derivable from stated rules of the language." However, that does require the reader to exercise some mental gymnastics in cases like these. If you prefer a more explicit version, I recommend this one. I believe it to be correct but would be interested if anybody spots any flaws: https://miasap.se/obnc/type-compatibility.html Regards, Chris Burrows CFB Software https://www.astrobe.com
Chris Where does Karl Landström have the missing info from? a) own interpretation of the report b) compiler code If a) who says this list is correct? If b) the special case of ARRAY OF BYTE is missing. br Jörg
Am 16.06.2020 um 03:40 schrieb Chris Burrows <chris@cfbsoftware.com>:
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of chris Sent: Tuesday, 16 June 2020 5:37 AM To: ETH Oberon and related systems Subject: Re: [Oberon] Type compatibility rules for Pointers
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.
There has been much debate about this in the past. Not all of the rules are explicitly spelt out in the Language Report. In the introduction to the Language Report Wirth says:
“… What remains unsaid is mostly left so intentionally, either because it is derivable from stated rules of the language…”
However, that does require the reader to exercise some mental gymnastics in cases like these. If you prefer a more explicit version, I recommend this one. I believe it to be correct but would be interested if anybody spots any flaws:
https://miasap.se/obnc/type-compatibility.html
Regards, Chris Burrows CFB Software https://www.astrobe.com
-- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Jörg I seem to recall being involved, with others, in an email review of this list. My recollection was that is was somebody else rather than Karl – there may be another similar list in existence. As far as I know it is solely an unofficial interpretation of the report. As he says in the introduction: “To fill in the missing pieces, appendix A from The Programming Language Oberon-2 (1993) by Hanspeter Mössenböck and Niklaus Wirth is used here as a template, with adjustments for the 2016 edition of Oberon.” a) I’ll rephrase that question: Who says this list is incorrect and why? b) As I have stated here before, the Project Oberon compiler is not a reference compiler. It includes some additions, some variations and some exclusions from the Language Report. It is highly likely the same applies to every other Oberon compiler in existence – in the real world there will inevitably be some grey areas. The special case of ARRAY OF BYTE (when equivalenced to another type of the same size) is one such example. It is an undocumented extended feature of the Project Oberon compiler. It is not currently part of the language definition and cannot be expected to work in all Oberon compilers. Regards, Chris Burrows CFB Software https://www.astrobe.com From: Joerg [mailto:joerg.straube@iaeth.ch] Sent: Tuesday, 16 June 2020 3:00 PM To: chris@cfbsoftware.com; ETH Oberon and related systems Subject: Re: [Oberon] Type compatibility rules for Pointers Chris Where does Karl Landström have the missing info from? a) own interpretation of the report b) compiler code If a) who says this list is correct? If b) the special case of ARRAY OF BYTE is missing. br Jörg Am 16.06.2020 um 03:40 schrieb Chris Burrows <chris@cfbsoftware.com <mailto:chris@cfbsoftware.com> >:
-----Original Message-----
From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of chris
Sent: Tuesday, 16 June 2020 5:37 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Type compatibility rules for Pointers
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.
There has been much debate about this in the past. Not all of the rules are explicitly spelt out in the Language Report. In the introduction to the Language Report Wirth says: “… What remains unsaid is mostly left so intentionally, either because it is derivable from stated rules of the language…” However, that does require the reader to exercise some mental gymnastics in cases like these. If you prefer a more explicit version, I recommend this one. I believe it to be correct but would be interested if anybody spots any flaws: https://miasap.se/obnc/type-compatibility.html Regards, Chris Burrows CFB Software https://www.astrobe.com -- Oberon@lists.inf.ethz.ch <mailto:Oberon@lists.inf.ethz.ch> mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
I thought so. I have found the other set of rules that I was thinking of. They were proposed by Luca Boasso: https://github.com/lboasso/OberonRISC5/blob/master/TypeRules.md There are differences between Luca’s and Karl’s if anybody is interested in investigating further. Regards, Chris Burrows CFB Software https://www.astrobe.com/RISC5 From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Chris Burrows Sent: Tuesday, 16 June 2020 3:48 PM To: ETH Oberon and related systems Subject: Re: [Oberon] Type compatibility rules for Pointers Jörg I seem to recall being involved, with others, in an email review of this list. My recollection was that is was somebody else rather than Karl – there may be another similar list in existence. As far as I know it is solely an unofficial interpretation of the report. As he says in the introduction: …… From: Joerg [mailto:joerg.straube@iaeth.ch] Sent: Tuesday, 16 June 2020 3:00 PM To: chris@cfbsoftware.com <mailto:chris@cfbsoftware.com> ; ETH Oberon and related systems Subject: Re: [Oberon] Type compatibility rules for Pointers Chris Where does Karl Landström have the missing info from? a) own interpretation of the report b) compiler code If a) who says this list is correct? If b) the special case of ARRAY OF BYTE is missing. br Jörg Am 16.06.2020 um 03:40 schrieb Chris Burrows <chris@cfbsoftware.com <mailto:chris@cfbsoftware.com> >:
-----Original Message-----
From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of chris
Sent: Tuesday, 16 June 2020 5:37 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Type compatibility rules for Pointers
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.
There has been much debate about this in the past. Not all of the rules are explicitly spelt out in the Language Report. In the introduction to the Language Report Wirth says: “… What remains unsaid is mostly left so intentionally, either because it is derivable from stated rules of the language…” However, that does require the reader to exercise some mental gymnastics in cases like these. If you prefer a more explicit version, I recommend this one. I believe it to be correct but would be interested if anybody spots any flaws: https://miasap.se/obnc/type-compatibility.html Regards, Chris Burrows CFB Software https://www.astrobe.com -- Oberon@lists.inf.ethz.ch <mailto:Oberon@lists.inf.ethz.ch> mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
Yes, you’re right. It’s not in the Oberon report. However the inner core heavily depends on it. NW sees Oberon is a high level language able to do low level programming. Proof: one can write a complete OS with it. This statement is only true, if you have these “undocumented” extensions in the compiler. If you don’t have the ARRAY OF BYTE feature, you could do it the pure Oberon way with type extensions. But then you don’t have the automatic checks whether the type sizes of the parameters really fit. You would have to add runtime checks. The other one being that the compiler accepts “0E7000000H” as INTEGER. Strictly speaking, it’s not allowed (either an INTEGER is negative. In Oberon you can only generate negative numbers by involving a “-“ somewhere. Or it’s positive, then it’s too big for an 31bit number + sign bit) As you know the compiler is full with these constants. The Oberon Report is short but unfortunately not complete. br Jörg Von: Oberon <oberon-bounces@lists.inf.ethz.ch> im Auftrag von Chris Burrows <chris@cfbsoftware.com> Antworten an: <chris@cfbsoftware.com>, ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Datum: Dienstag, 16. Juni 2020 um 08:19 An: ETH Oberon and related systems <oberon@lists.inf.ethz.ch> Betreff: Re: [Oberon] Type compatibility rules for Pointers Jörg I seem to recall being involved, with others, in an email review of this list. My recollection was that is was somebody else rather than Karl – there may be another similar list in existence. As far as I know it is solely an unofficial interpretation of the report. As he says in the introduction: “To fill in the missing pieces, appendix A from The Programming Language Oberon-2 (1993) by Hanspeter Mössenböck and Niklaus Wirth is used here as a template, with adjustments for the 2016 edition of Oberon.” I’ll rephrase that question: Who says this list is incorrect and why? As I have stated here before, the Project Oberon compiler is not a reference compiler. It includes some additions, some variations and some exclusions from the Language Report. It is highly likely the same applies to every other Oberon compiler in existence – in the real world there will inevitably be some grey areas. The special case of ARRAY OF BYTE (when equivalenced to another type of the same size) is one such example. It is an undocumented extended feature of the Project Oberon compiler. It is not currently part of the language definition and cannot be expected to work in all Oberon compilers. Regards, Chris Burrows CFB Software https://www.astrobe.com From: Joerg [mailto:joerg.straube@iaeth.ch] Sent: Tuesday, 16 June 2020 3:00 PM To: chris@cfbsoftware.com; ETH Oberon and related systems Subject: Re: [Oberon] Type compatibility rules for Pointers Chris Where does Karl Landström have the missing info from? a) own interpretation of the report b) compiler code If a) who says this list is correct? If b) the special case of ARRAY OF BYTE is missing. br Jörg Am 16.06.2020 um 03:40 schrieb Chris Burrows <chris@cfbsoftware.com>:
-----Original Message-----
From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of chris
Sent: Tuesday, 16 June 2020 5:37 AM
To: ETH Oberon and related systems
Subject: Re: [Oberon] Type compatibility rules for Pointers
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.
There has been much debate about this in the past. Not all of the rules are explicitly spelt out in the Language Report. In the introduction to the Language Report Wirth says: “… What remains unsaid is mostly left so intentionally, either because it is derivable from stated rules of the language…” However, that does require the reader to exercise some mental gymnastics in cases like these. If you prefer a more explicit version, I recommend this one. I believe it to be correct but would be interested if anybody spots any flaws: https://miasap.se/obnc/type-compatibility.html Regards, Chris Burrows CFB Software https://www.astrobe.com -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2020-06-15 21:09, chris wrote:
TYPE R = RECORD i : INTEGER END; P1 = POINTER TO R; P2 = POINTER TO R;
PROCEDURE Test(); VAR p1 : P1; p2 : P2; BEGIN NEW(p1); NEW(p2); IF p1 IS P2 THEN (* true *) END; p1 := p2; END Test; [...] I am a bit confused that p1 := p2 compiles without errors. Section 6.4 in the language report says that "Pointer types inherit the extension relation of their base types, if there is any." Also P2 is a (trivial) extension of P1 and vice versa.
August
Section 6.4 in the language report says that "Pointer types inherit
On Mon, 15 Jun 2020 21:43:48 +0200, August Karlstrom wrote: the extension relation of their base types, if there is any." Also P2 is a (trivial) extension of P1 and vice versa. Right. But it should be mentioned in the list of exceptions for assignment compatibility (9.1 in the Oberon-07 report) in the same way as record types are mentioned, I believe. Greetings chris
On Mon, 15 Jun 2020 21:43:48 +0200 August Karlstrom <fusionfile@gmail.com> wrote:
Section 6.4 in the language report says that "Pointer types inherit the extension relation of their base types, if there is any." Also P2 is a (trivial) extension of P1 and vice versa.
Oberon-07 allows [no only] array assignments, SYSTEM.COPY() not needed in many situations. I found this even more interesting.. MODULE Types; (*type compatibility*) TYPE P1 = POINTER TO R1; P2 = POINTER TO R2; R1 = RECORD END; R2 = RECORD (R1) END; PROCEDURE Test*; VAR p1: P1; p2: P2; BEGIN NEW(p1); NEW(p2); (*possible*) IF p1 IS p2 THEN (*true*) END ; p1 := p2; (*not possible*) IF p2 IS p1 THEN (*true*) END ; p2 := p1; END Test; END Types.Test -- Tomas Kral <thomas.kral@email.cz>
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of Tomas Kral Sent: Tuesday, 16 June 2020 4:38 PM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] Type compatibility rules for Pointers
I found this even more interesting..
MODULE Types; (*type compatibility*) TYPE P1 = POINTER TO R1; P2 = POINTER TO R2;
R1 = RECORD END; R2 = RECORD (R1) END;
PROCEDURE Test*; VAR p1: P1; p2: P2; BEGIN NEW(p1); NEW(p2);
(*possible*) IF p1 IS p2 THEN (*true*) END ; p1 := p2;
(*not possible*) IF p2 IS p1 THEN (*true*) END ; p2 := p1;
END Test; END Types.Test
If you do not understand why this is so, the most comprehensible explanation of this behaviour, that I have found, is in: Section 5.2 Compatibility of a Base Type and Its Extension, in Hanspeter Mössenböck's book: Object-Oriented Programming in Oberon-2. http://ssw.jku.at/Research/Books/Oberon2.pdf Regards, Chris Burrows CFB Software https://www.astrobe.com/RISC5
Section 5.2 Compatibility of a Base Type and Its Extension, in Hanspeter Mössenböck's book: Object-Oriented Programming in Oberon-2.
Hi Chris, Yes thank you for the pointer, been there, done that, have some understanding. Type extension, and procedure variables, are the basis of OOP. I learn to use, though often surprised things are possible, unlike in Modula-2. Seeing some ETH Oberon modules, COPY() is quite frequently used, where in Oberon-07, just `:=' assignment will do. -- Tomas Kral <thomas.kral@email.cz>
You're right := operator on ARRAYs was not allowed in Oberon-2 but it is in Oberon-7 Jörg Am 16.06.20, 09:54 schrieb "Oberon im Auftrag von Tomas Kral" <oberon-bounces@lists.inf.ethz.ch im Auftrag von thomas.kral@email.cz>: > Section 5.2 Compatibility of a Base Type and Its Extension, in > Hanspeter Mössenböck's book: Object-Oriented Programming in Oberon-2. Hi Chris, Yes thank you for the pointer, been there, done that, have some understanding. Type extension, and procedure variables, are the basis of OOP. I learn to use, though often surprised things are possible, unlike in Modula-2. Seeing some ETH Oberon modules, COPY() is quite frequently used, where in Oberon-07, just `:=' assignment will do. -- Tomas Kral <thomas.kral@email.cz> -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
participants (8)
-
August Karlstrom -
chris -
Chris Burrows -
Diego Sardina -
Joerg -
Jörg -
Michael Schierl -
Tomas Kral