Clarifying type compatibility in Oberon-07
Oberon-2 has the following definition of *same type* in appendix A in the language report: 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. As far as I understand, Oberon-07 uses structural equivalence for array and procedure types so we must add two paragraphs to this list: 4. Ta and Tb are array types whose element types and lengths are the same, or 5. Ta and Tb are procedure types whose formal parameter lists match. In appendix A we also need to * remove SHORTINT and LONGINT and add BYTE, * remove type inclusion, * add two paragraphs to the definition of "assignment compatible": 8. Te is BYTE and Tv is INTEGER or vice versa; 9. Te is an open array and Tv is an array with the same element type (and length?) as Te. Is Oberon-07 compatible with appendix A after these changes have been made? http://www.math.bas.bg/bantchev/place/oberon/Oberon2-Report.pdf Regards, August
In my point of view Appendix A for Oberon-07 would look like this. Joerg Appendix A: Definition of terms Integer types BYTE, INTEGER, LONGINT (not official but compiler allows as if LONGINT = INTEGER) Real types REAL, LONGREAL Numeric types integer types, real types 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. Equal types Two types Ta and Tb are equal if 1. Ta and Tb are the same type, or 2. Ta and Tb are open array types with equal element types, or 3. Ta and Tb are procedure types whose formal parameter lists match. Type inclusion Integer types include (the values of) smaller numeric types according to the following hierarchy: LONGREAL >= REAL >= LONGINT = INTEGER >= BYTE Type extension (base type) Given a type declaration Tb = RECORD (Ta) ... END, Tb is a direct extension of Ta, and Ta is a direct base type of Tb. A type Tb is an extension of a type Ta (Ta is a base type of Tb) if 1. Ta and Tb are the same types, or 2. Tb is a direct extension of an extension of Ta 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. 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 integer types and Tv includes Te; 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. Tv is a procedure type and e is the name of a procedure whose formal parameters match those of Tv. Array compatible An actual parameter a of type Ta is array compatible with a formal parameter f of type Tf if 1. Tf and Ta are the same type, or 2. Tf is an open array, Ta is any array, and their element types are array compatible, or 3. Tf is ARRAY OF CHAR and a is a string. 4. Tf is ARRAY n OF BYTE and Ta has length n. Expression compatible For a given operator, the types of its operands are expression compatible if they conform to the following table (which shows also the result type of the expression). Character arrays that are to be compared must contain 0X as a terminator. Type T1 must be an extension of type T0: operator 1st op 2nd op result type + * numeric type numeric type numeric type / real type real type real type + * / SET SET SET DIV MOD integer type integer type integer type OR & ~ BOOLEAN BOOLEAN BOOLEAN = # < <= > >= numeric numeric BOOLEAN CHAR CHAR BOOLEAN character array, string character array, string BOOLEAN = # BOOLEAN BOOLEAN BOOLEAN SET SET BOOLEAN NIL, pointer type T0 or T1 NIL, pointer type T0 or T1 BOOLEAN procedure type T, NIL procedure type T, NIL BOOLEAN IN integer type SET BOOLEAN IS type T0 type T1 BOOLEAN Matching formal parameter lists Two formal parameter lists match if 1. they have the same number of parameters, and 2. they have either the same function result type or none, and 3. parameters at corresponding positions have equal types, and 4. parameters at corresponding positions are both either value or variable parameters.
On 2017-10-04 18:11, Jörg wrote:
In my point of view Appendix A for Oberon-07 would look like this.[...]
(Your strikethroughs and colors don't show in ASCII so I cannot include any quoted context.) Our goal in this thread is to reach a consensus about how a conforming Oberon-07 compiler should behave (when it comes to type compatibility) and document it using appendix A in the Oberon-2 report as a template. Note also that Niklaus Wirth has said that his implementation (the PO2003 compiler) should not be taken as a reference for compiler developers. * LONGINT is not in the report so it should be dropped. * Since integers and integer variables can be assigned to byte variables the type inclusion concept makes no sense in Oberon-07. It should be dropped from the appendix. * Under "Assignment compatible" you don't mention assignment of open arrays. * Paragraph 4 of "Array compatible" (ARRAY n OF BYTE...) must be a compiler extension since it cannot be deduced from the language report. You never mention structural equivalence in assignment of expressions of array or procedure type, so the question is if that is an undocumented "language extension" in the PO2003 compiler. Any more comments? -- August
Hi August see inline
Am 04.10.2017 um 21:00 schrieb August Karlstrom <fusionfile@gmail.com>:
On 2017-10-04 18:11, Jörg wrote:
In my point of view Appendix A for Oberon-07 would look like this.[...]
(Your strikethroughs and colors don't show in ASCII so I cannot include any quoted context.)
Our goal in this thread is to reach a consensus about how a conforming Oberon-07 compiler should behave (when it comes to type compatibility) and document it using appendix A in the Oberon-2 report as a template. Note also that Niklaus Wirth has said that his implementation (the PO2003 compiler) should not be taken as a reference for compiler developers.
* LONGINT is not in the report so it should be dropped.
Strictly speaking, you are right: LONGINT is NOT part of the language report. NW’s source code is full of LONGINTs. This is because he took quite some code from the old compiler and simplified it. My assumption is: he was too lazy to write in almost all MODULES as first statement TYPE LONGINT = INTEGER, that he decided to include that statement in the compiler. That was the reason why I took the green color and not the red color. As a general rule of thumb: NW seems to apply the following rule: If something has to have 4 bytes, he calls it LONGINT, If the size is not so important (index, counter..) he seems to declare it as INTEGER. The size of INTEGER (and SET) is not mentioned in the report, it’s fixed to a specific value by the compiler.
* Since integers and integer variables can be assigned to byte variables the type inclusion concept makes no sense in Oberon-07. It should be dropped from the appendix.
I’m open to that point. I liked the idea of inclusion. E.g. what is the type of c in CONST c = 30; ? Is it BYTE or is INTEGER? This was the reason why I let it in, but restricted it to integer type and adapted rule Assignment 2 accordingly. But feel free.
* Under "Assignment compatible" you don't mention assignment of open arrays.
open arrays only exist as formal parameter of a procedure not as a variable. Assignment rules are for variables. In my point of view open arrays are covered in Array rule 2.
* Paragraph 4 of "Array compatible" (ARRAY n OF BYTE...) must be a compiler extension since it cannot be deduced from the language report.
That’s indeed strange. In one of the previous posts Chris highlighted that this was possible. I was not aware of this and was thinking the same. If I remember correctly, I browsed then thru the report and indeed found a sentence explicitly mentioning it. I re-did that today, I can’t find it back anymore. Seems, I’m getting old… Feel free to delete it. I have to admit it’s a feature that simplifies things. It frees your (low level) code of a lot of SYSTEM.VAL(LONGINT, …)
You never mention structural equivalence in assignment of expressions of array or procedure type, so the question is if that is an undocumented "language extension" in the PO2003 compiler.
In my point of view this topic is covered by the last chapter titled „Matching formal parameter lists"
Any more comments?
-- August -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-04 22:27, Jörg wrote:
Am 04.10.2017 um 21:00 schrieb August Karlstrom <fusionfile@gmail.com>: * Since integers and integer variables can be assigned to byte variables the type inclusion concept makes no sense in Oberon-07. It should be dropped from the appendix.
I’m open to that point. I liked the idea of inclusion. E.g. what is the type of c in CONST c = 30; ? Is it BYTE or is INTEGER? This was the reason why I let it in, but restricted it to integer type and adapted rule Assignment 2 accordingly. But feel free.
The type of 30 is INTEGER and therefor the type of c is also INTEGER. Note that there are no BYTE literals.
* Under "Assignment compatible" you don't mention assignment of open arrays.
open arrays only exist as formal parameter of a procedure not as a variable. Assignment rules are for variables. In my point of view open arrays are covered in Array rule 2.
I'm talking about paragraph 4 in section 9.1 of the Oberon-7 language report: http://miasap.se/obnc/oberon-report.html#sec9
* Paragraph 4 of "Array compatible" (ARRAY n OF BYTE...) must be a compiler extension since it cannot be deduced from the language report.
That’s indeed strange. In one of the previous posts Chris highlighted that this was possible. I was not aware of this and was thinking the same. If I remember correctly, I browsed then thru the report and indeed found a sentence explicitly mentioning it. I re-did that today, I can’t find it back anymore. Seems, I’m getting old… Feel free to delete it. I have to admit it’s a feature that simplifies things. It frees your (low level) code of a lot of SYSTEM.VAL(LONGINT, …)
OK, we will wait for Chris and see what he has to say about it.
You never mention structural equivalence in assignment of expressions of array or procedure type, so the question is if that is an undocumented "language extension" in the PO2003 compiler.
In my point of view this topic is covered by the last chapter titled „Matching formal parameter lists" If I understand correctly, with the variable declarations
a: ARRAY 10 OF INTEGER b: ARRAY 10 OF INTEGER p: PROCEDURE q: PROCEDURE The following assignments are accepted by the PO2003 compiler: a := b p := q How is this covered by the rules in "Matching formal parameter lists"? This is not related to procedure calls. -- August
August
* Under "Assignment compatible" you don't mention assignment of open arrays.
open arrays only exist as formal parameter of a procedure not as a variable. Assignment rules are for variables. In my point of view open arrays are covered in Array rule 2.
I'm talking about paragraph 4 in section 9.1 of the Oberon-7 language a: ARRAY 10 OF INTEGER; b: ARRAY 10 OF INTEGER; a := b;
9.1.1 is covered by Assignment rule 5 9.1.2 is covered by Assignment rule 6 9.1.3 is covered by Assignment rule 3 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. 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..) br Jörg
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
August ** 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. We have to define whether NWs compiler is the master or the NWs report is the master. NW seems to like the idea that source code is the most accurate documentation… :-P * I guess 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 assignment of POINTERs is in my point of view somehow covered already by the extension definition. T can be seen as the simplest form of the extension of T itself. * 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 No evidence in the report. Perhaps a sloppy implementation of the open array assignment thing. * 5. Ta and Tb are pointer types whose pointer base types are the same, or covered by the extension rule as I see the base type is the simplest form of an extension of itself * 6. Ta and Tb are procedure types whose formal parameter lists match. Isn’t this covered by Assignment rule 7 Jörg
On 2017-10-05 11:50, Jörg wrote:
We have to define whether NWs compiler is the master or the NWs report is the master.
The language report is the master according to NW and this is of course how it should be.
* MODULE M; * * TYPE * T = RECORD END; * * VAR * p: POINTER TO T; * q: POINTER TO T; * * BEGIN * p := q * END M.
This assignment of POINTERs is in my point of view somehow covered already by the extension definition. T can be seen as the simplest form of the extension of T itself.
It's the "in my point" and "somehow" we want to avoid and instead have a clear and complete definition of type compatibility like Oberon-2 has.
* 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 No evidence in the report. Perhaps a sloppy implementation of the open array assignment thing.
Yes maybe, but at least Chris (one of the master interpreters of NW's writings) claims, if I understand him correctly, that it's somehow implied by paragraph 9.1.4: "An open array may be assigned to an array of equal base type."
* 5. Ta and Tb are pointer types whose pointer base types are the same, or covered by the extension rule as I see the base type is the simplest form of an extension of itself
* 6. Ta and Tb are procedure types whose formal parameter lists match. Isn’t this covered by Assignment rule 7
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. -- August
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: 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 Assignment rule 1 uses „same type". The things NOT covered by „same type“ are mentioned explicitly with own assignment rules. 4. Ta and Tb are pointer types whose pointer base types are the same, or This rule is not needed, as it is covered by Assignment rule 4, assuming T is an extension of T itself. 5. Ta and Tb are procedure types whose formal parameter lists match. This rule is not needed as it covered by Assignment rule 7. br Jörg
August
4. Ta and Tb are pointer types whose pointer base types are the same, or This rule is not needed, as it is covered by Assignment rule 4, assuming T is an extension of T itself.
When implementing assignment rule 4, you start with the type Te and go through the list of extension types until you reach Tv (assignment allowed) or the end of the list (assignment not allowed). As in your example Te is Tv, your loop ends immediately with the result (assignment allowed). br Jörg
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
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. I can agree on 2, 8 and 9. Why do you want to change the original wording of 7. br Jörg
On 2017-10-05 14:28, Jörg wrote:
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.
I can agree on 2, 8 and 9. Why do you want to change the original wording of 7.
It's for the use of structural equivalence in assignment of procedure *variables*. Anyway, I have been in contact with Niklaus Wirth and he says that structural equivalence used in assignment of (non-open) array and procedure variables should be considered as "an addition to the language definition". Therefor list item 7 above should be left unchanged as you suggested. -- August
It's for the use of structural equivalence in assignment of procedure *variables*. This is allowed already with the original wording of Assignment rule 7. In the statement p1 := p2, the procedure variable p2 “is a name of a procedure whose formal parameters match those of Tv”. br Jörg
On 2017-10-05 17:39, Jörg wrote:
It's for the use of structural equivalence in assignment of procedure *variables*.
This is allowed already with the original wording of Assignment rule 7. In the statement p1 := p2, the procedure variable p2 “is a name of a procedure whose formal parameters match those of Tv”.
There is a subtle difference here. It says "Tv is a procedure type and e is the name of a procedure whose formal parameters match those of Tv." It means that the expression e is the name of a procedure (constant). Anyway, as I mentioned after contacting NW, using structural equivalence for p1 := p2 where p2 is a procedure variable is not portable. -- August
Okay. NW’s compiler allows it. If you write p2(4,5) it’s debatable whether p2 is a “name of a procedure“... Jörg
Am 05.10.2017 um 17:48 schrieb August Karlstrom <fusionfile@gmail.com>:
On 2017-10-05 17:39, Jörg wrote: It's for the use of structural equivalence in assignment of procedure *variables*. This is allowed already with the original wording of Assignment rule 7. In the statement p1 := p2, the procedure variable p2 “is a name of a procedure whose formal parameters match those of Tv”.
There is a subtle difference here. It says "Tv is a procedure type and e is the name of a procedure whose formal parameters match those of Tv." It means that the expression e is the name of a procedure (constant). Anyway, as I mentioned after contacting NW, using structural equivalence for p1 := p2 where p2 is a procedure variable is not portable.
-- August -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-05 17:56, Jörg wrote:
Okay. NW’s compiler allows it. If you write p2(4,5) it’s debatable whether p2 is a “name of a procedure“...
Assignment rule 7 wouldn't be so verbose if it wasn't to specify that the expression must be a procedure constant. So Oberon-2 as do "standard" Oberon-07 uses structural equivalence only for procedure variable initialization with a procedure (constant). -- August
As with the pointer assignment discussed earlier, the structural equivalence for procedures variables is rather a by-product. As you have to code the structural equivalence anyhow for procedure constants, you evaluate the expression e and start comparing formal parameters :-) ORP.CompTypes: … (t0.form = ORB.Proc) & (t1.form = ORB.Proc) & EqualSignatures(t0, t1) … Jörg Am 05.10.17, 18:14 schrieb "Oberon im Auftrag von August Karlstrom" <oberon-bounces@lists.inf.ethz.ch im Auftrag von fusionfile@gmail.com>: On 2017-10-05 17:56, Jörg wrote: > Okay. NW’s compiler allows it. > If you write p2(4,5) it’s debatable whether p2 is a “name of a procedure“... Assignment rule 7 wouldn't be so verbose if it wasn't to specify that the expression must be a procedure constant. So Oberon-2 as do "standard" Oberon-07 uses structural equivalence only for procedure variable initialization with a procedure (constant). -- August -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-05 19:05, Jörg wrote:
As with the pointer assignment discussed earlier, the structural equivalence for procedures variables is rather a by-product.
But sometimes the by-product is something you don't want. Name equivalence has its semantical advantages when you want to prevent a mix of apples and oranges. -- August
Dear all, Last year I was exchanging emails with Prof. Wirth to discuss Oberon-07's type system. That discussion lead to updates to the compiler (see Wirth's news.txt: 20160508, 20160501, 20160418 and 20160410). Recently, I had similar private conversations with Andreas Pirklbauer. I would like to present here, to a wider audience, what I think Oberon-07 type rules should be, with a set of fixes to ORP.Mod to reflect these rules. The type rules are adapted from the Appendix A of the Oberon-2 report, and are an attempt to marry Oberon-07 new rules with the proven ones of Oberon-2. The fixes to ORP.Mod are as minimal as possible and are aimed to weed out inconsistencies of the current implementation. I have tried these changes for the last half year with no issues, I will later share a set of tests that I made to verify the implementation. I think that discussing the rules in plain English is not enough, because different people have different interpretations. For this reason I ask you to look at the changes in the code. I have added comments like "(* Type Rule X *)" above the code that handles the implementation of Rule X from the TypeRules.txt file. I have created a new GitHub repository to track the changes and share them. Please fell free to contribute, the link is: https://github.com/lboasso/ OberonRISC5 In particular here is the TypeRules.txt file: https://raw.githubusercontent. com/lboasso/OberonRISC5/master/TypeRules.txt And here is the diff of the changes I made to ORP.Mod: https://github.com/lboasso/OberonRISC5/commit/3f5b5c3d5fbf632e82902e9fbbaf93 ef8285e577#diff-ec269f2dcbbad1d06c87c72169d0fcf2 I hope this would help the current discussion. My hope is to reach a consensus, that could be eventually blessed by Prof. Wirth. I do not claim to have found the final rules, but this could be a step in the right direction with your feedback. Regards, Luca Boasso On Thu, Oct 5, 2017 at 10:48 AM, August Karlstrom <fusionfile@gmail.com> wrote:
On 2017-10-05 19:05, Jörg wrote:
As with the pointer assignment discussed earlier, the structural equivalence for procedures variables is rather a by-product.
But sometimes the by-product is something you don't want. Name equivalence has its semantical advantages when you want to prevent a mix of apples and oranges.
-- August -- Oberon@lists.inf.ethz.ch mailing list for ETH Oberon and related systems https://lists.inf.ethz.ch/mailman/listinfo/oberon
On 2017-10-06 05:52, Luca Boasso wrote:
Dear all,
Last year I was exchanging emails with Prof. Wirth to discuss Oberon-07's type system.
NW tends to come up with new ideas quite often so his opinion today may be different from last year.
That discussion lead to updates to the compiler (see Wirth's news.txt: 20160508, 20160501, 20160418 and 20160410).
If I remember correctly this was when type aliases were reintroduced (identdef = typeName), something he mentioned he don't really like but added because people requested it.
The type rules are adapted from the Appendix A of the Oberon-2 report, and are an attempt to marry Oberon-07 new rules with the proven ones of Oberon-2.
Yes, if you read this thread you will find that this is what I have already suggested.
The fixes to ORP.Mod are as minimal as possible and are aimed to weed out inconsistencies of the current implementation. I have tried these changes for the last half year with no issues, I will later share a set of tests that I made to verify the implementation.
I think that discussing the rules in plain English is not enough,
At least for me, appendix A in the Oberon-2 report is sufficiently clear for describing Oberon-2's type rules.
I hope this would help the current discussion. My hope is to reach a consensus, that could be eventually blessed by Prof. Wirth. I do not claim to have found the final rules, but this could be a step in the right direction with your feedback. Nice effort. I have been in contact with NW this week and I asked him about the structural equivalence used in assignment of [non-open] array and procedure variables. Here is my question:
"I ideally want to write long-lived programs that can be compiled with different implementations of Oberon07. What I wonder is basically if this structural equivalence is to be seen as a language extension of your compiler?" His reply was: "Yes, I consider this type compatibility as an addition tothe language definition. I think it makes sense, and it is easy to implement." I realize now that it is not really clear if he means that the structural equivalence is a "non-standard" feature, or if the language definition has changed, implying that every Oberon-07 compiler should work this way. What do you think? -- August
-----Original Message----- From: Oberon [mailto:oberon-bounces@lists.inf.ethz.ch] On Behalf Of August Karlstrom Sent: Thursday, 5 October 2017 9:01 PM To: oberon@lists.inf.ethz.ch Subject: Re: [Oberon] Clarifying type compatibility in Oberon-07
On 2017-10-05 11:50, J rg wrote:
We have to define whether NWs compiler is the master or the NWs report is the master.
The language report is the master according to NW and this is of course how it should be.
Agreed. The language report is the master. NW's RISC compiler has a few useful features that are not included in the report (e.g. special ARRAY OF BYTE compatibility that I mentioned recently) so must be regarded as language extensions, for now at least. It is also missing at least one feature i.e. numeric CASE statements. We have implemented numeric CASE statements and some of the RISC5 compiler language extensions in the Astrobe compilers. We have always tried to ensure that these are kept to the absolute minimum and have identified them as extensions along with any other implementation specific details (e.g. restrictions and clarifications) in the accompanying release notes and documentation. Regards, Chris Burrows CFB Software http://www.astrobe.com
participants (4)
-
August Karlstrom -
Chris Burrows -
Jörg -
Luca Boasso