augustk wrote:
So this module is valid:
Yes - I believe so. Wirth's RISC5 compiler allows it although that is not necessarily conclusive as he has implemented some language extensions not included in the Report.
augustk wrote:How can we come to that conclusion from reading the Oberon report?
It is not obvious to me. You could if you interpreted
same type as referring to
structure equivalence instead of (e.g. Pascal's)
name equivalence. That is not clearly defined in the report as far as I can see. However, structure equivalence
is explicitly ruled out in the case of records, the other type of structure, by the exceptional assignment rule:
3. In the case of records, the type of the source must be an extension of the type of the destination.
A good explanation of the difference between the two forms of type equivalence is here:
https://people.cs.clemson.edu/~turner/c ... ch5_3.html
Note that the following two Oberon examples are now also valid according to the 3.5.2016 Version of the report. They might provide some food for thought?
Code: Select all
MODULE M;
TYPE
String = ARRAY 32 OF CHAR;
NewString = String;
VAR
s: String;
s1: NewString;
BEGIN
s := "test";
s1 := s
END M.
Code: Select all
MODULE M;
TYPE
String = ARRAY 32 OF CHAR;
VAR
s: String;
s1: ARRAY 32 OF CHAR;
PROCEDURE P(s: ARRAY OF CHAR);
BEGIN
s1 := s
END P;
BEGIN
s := "test";
P(s)
END M.