Page 1 of 4
Oberon Report Update 2016-05-01
Posted: Sun May 01, 2016 3:05 pm
by augustk
The Oberon Report has been updated again. The changes are:
1. The three grammar productions
Code: Select all
TypeDeclaration = identdef "=" StrucType.
StrucType = ArrayType | RecordType | PointerType | ProcedureType.
type = qualident | StrucType.
have been reduced to
Code: Select all
TypeDeclaration = identdef "=" type.
type = qualident | ArrayType | RecordType | PointerType | ProcedureType.
(I assume that
qualident still cannot be a basic type.)
2. Strings assigned to character arrays are always null-terminated.
3. Open arrays can be assigned to arrays with the same base type.
Re: Oberon Report Update 2016-05-01
Posted: Sun May 01, 2016 6:48 pm
by kevinhely
(I assume that qualident still cannot be a basic type.)
Why? INTEGER is a qualident.
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 3:12 am
by cfbsoftware
augustk wrote:(I assume that qualident still cannot be a basic type.)
qualident can be a basic type. There is an example of this use in the FileDir module in Project Oberon 2013 :
DiskAdr = INTEGER;
It is even possible to write
REAL = INTEGER;
but I wouldn't recommend it
This feature, i.e. being able to rename / alias types, is already implemented in the current versions of Astrobe. We we will only have to update the documentation as it is no longer considered to be a language extension.
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 7:13 am
by augustk
cfbsoftware wrote:qualident can be a basic type. There is an example of this use in the FileDir module in Project Oberon 2013
If my memory serves me correctly, I have read somewhere a text by Niklaus Wirth where he says that the right hand side of a type declaration must be a structured type. My "default" understanding would be that any type is allowed. Do you remember if an earlier version of the language had this restriction? Otherwise it must be something I have made up.
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 8:17 am
by augustk
As I understand it, the decision between "null-terminated if needed" and "always null-terminated" character arrays is a trade off between declaration interpretation complexity and algorithm complexity.
Let's consider the declaration
With the "null-terminated if needed" approach the variable can hold a name of up to 32 characters; as simple and obvious as can be. On the other hand, with the "always null-terminated" approach we need to (remember to) subtract one element and conclude that the array can hold a name of only up to 31 characters. The alternative is to add one element explicitly as a remainder:
Now, let's look at the code for computing the length of the character array. With the "null-terminated if needed" approach we need to look for both the the null character and the end of the array:
Code: Select all
i := 0;
WHILE (i < LEN(name)) & (name[i] # 0X) DO
INC(i)
END
With the "always null-terminated" approach we only need to look for the null character:
Code: Select all
i := 0;
WHILE name[i] # 0X DO
INC(i)
END
The latter is more efficient and regular.
Are there any aspects I have missed?
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 8:28 am
by Stefano
cfbsoftware wrote:augustk wrote:(I assume that qualident still cannot be a basic type.)
qualident can be a basic type. There is an example of this use in the FileDir module in Project Oberon 2013 :
DiskAdr = INTEGER;
It is even possible to write
REAL = INTEGER;
but I wouldn't recommend it
This feature, i.e. being able to rename / alias types, is already implemented in the current versions of Astrobe. We we will only have to update the documentation as it is no longer considered to be a language extension.
Isn't REAL a predeclared type so that REAL = INTEGER is a redeclaration?
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 8:35 am
by cfbsoftware
augustk wrote:If my memory serves me correctly, I have read somewhere a text by Niklaus Wirth where he says that the right hand side of a type declaration must be a structured type. My "default" understanding would be that any type is allowed. Do you remember if an earlier version of the language had this restriction? Otherwise it must be something I have made up.
It wasn't something you made up. The original Oberon Report (e.g. Revision 1. 10. 90) specified:
TypeDeclaration = identdef "=" type.
type = qualident | ArrayType | RecordType | PointerType | ProcedureType.
i.e. any type was allowed. The restriction to only allow structured types was introduced in Oberon-07:
TypeDeclaration = identdef "=" StrucType.
StrucType = ArrayType | RecordType | PointerType | ProcedureType.
type = qualident | StrucType.
This has now changed. The restriction has been removed in the latest (1.5.2016) revision of the report and we are back to the original definitions:
TypeDeclaration = identdef "=" type.
type = qualident | ArrayType | RecordType | PointerType | ProcedureType.
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 8:46 am
by cfbsoftware
Stefano wrote:Isn't REAL a predeclared type so that REAL = INTEGER is a redeclaration?
It's a predefined type e.g. like
ABS. It is not a reserved word like
BEGIN. e.g. in earlier versions of Oberon-07 you could have written:
PROCEDURE REAL(i: INTEGER);
BEGIN
END REAL;
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 8:53 am
by Stefano
cfbsoftware wrote:Stefano wrote:Isn't REAL a predeclared type so that REAL = INTEGER is a redeclaration?
It's a predefined type e.g. like
ABS. It is not a reserved word like
BEGIN. e.g. in earlier versions of Oberon-07 you could have written:
PROCEDURE REAL(i: INTEGER);
BEGIN
END REAL;
Section 6.1 states
6.1. Basic types
The following basic types are denoted by predeclared identifiers.
Re: Oberon Report Update 2016-05-01
Posted: Mon May 02, 2016 10:22 am
by augustk
cfbsoftware wrote:The restriction to only allow structured types was introduced in Oberon-07:
Code: Select all
TypeDeclaration = identdef "=" StrucType.
StrucType = ArrayType | RecordType | PointerType | ProcedureType.
type = qualident | StrucType.
Ah, of course. It's evident from the grammar. My bad.
Allowing only structured types in type declarations and having "null-terminated if needed" character arrays are obviously two of many changes to the Oberon language that Wirth has tried but reverted when they have turned out not to be beneficial in practice. I wonder if there are any changes that have been introduced, reverted and then reintroduced?