As far as I understand the above declaration should be valid also in the current version of Oberon-07. REAL is just a predefined identifier and, if I understand it correctly, any predefined identifier can be redefined (as a constant, type, variable or procedure).cfbsoftware wrote: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:Stefano wrote:Isn't REAL a predeclared type so that REAL = INTEGER is a redeclaration?
PROCEDURE REAL(i: INTEGER);
BEGIN
END REAL;
Oberon Report Update 2016-05-01
Re: Oberon Report Update 2016-05-01
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: Oberon Report Update 2016-05-01
That is correct. When I said they could be redefined in older versions of Oberon I meant as well as, not instead of, the current version. The explanation is based on the scoping rules. The key point here is that the standard identifiers of Oberon are considered to be declared in an imaginary scope enclosing the program. These can be redefined in the scope of a Module and can be further redefined within the scope of a Procedure.august wrote:As far as I understand the above declaration should be valid also in the current version of Oberon-07. REAL is just a predefined identifier and, if I understand it correctly, any predefined identifier can be redefined (as a constant, type, variable or procedure).
Re: Oberon Report Update 2016-05-01
In the latest revision "an open array may be assigned to an array of equal base type" but what about the other way around: Can an open array be the target of an assignment? After all, when a formal parameter is an open array a corresponding actual parameter can be an array of any length.
Re: Oberon Report Update 2016-05-01
From the Report: "The type of the expression must be the same as that of the designator" and "Strings can be assigned to any array of characters..."Can an open array be the target of an assignment?
Here's a question: if an open array is assigned to an array of equal base type but shorter length, is this a run-time error?
Re: Oberon Report Update 2016-05-01
What I mean is: Can a variable of type ARRAY n OF T or ARRAY OF T be assigned to a variable of type ARRAY OF T?kevinhely wrote:From the Report: "The type of the expression must be the same as that of the designator" and "Strings can be assigned to any array of characters..."Can an open array be the target of an assignment?
Assigning a string to an open array which doesn't fit should result in a run-time error. Therefor I conclude that it should be the same in the general case. No silent truncation in other words.kevinhely wrote:Here's a question: if an open array is assigned to an array of equal base type but shorter length, is this a run-time error?
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: Oberon Report Update 2016-05-01
No.augustk wrote:What I mean is: Can a variable of type ARRAY n OF T or ARRAY OF T be assigned to a variable of type ARRAY OF T?
How this situation is handled depends on the implementation. e.g. Normal modules that have been compiled using the latest Project Oberon 2013 compiler result in termination with a trap at runtime. However, when standalone modules (e.g. the bootloader) are compiled runtime checks are disabled and no errors are reported.kevinhely wrote:Here's a question: if an open array is assigned to an array of equal base type but shorter length, is this a run-time error?
Re: Oberon Report Update 2016-05-01
But why can open array be the source of an assignment then? I can't see the reason for allowing open arrays to be the source of an assignment but not the target (of a variable parameter). Please, enlighten me. In the sentence "An open array may be assigned to an array of equal base type" the phrase "an array of equal base type" can be interpreted as either a "closed" array or an open array.cfbsoftware wrote:No.augustk wrote:What I mean is: Can a variable of type ARRAY n OF T or ARRAY OF T be assigned to a variable of type ARRAY OF T?
-
- Site Admin
- Posts: 525
- Joined: Fri Dec 31, 2010 12:30 pm
- Contact:
Re: Oberon Report Update 2016-05-01
Because Wirth decided to allow it as an exceptional case. You can see an example of its use in Modules.error in Project Oberon 2013.augustk wrote:But why can open array be the source of an assignment then?
This is my reasoning:augustk wrote:Please, enlighten me. In the sentence "An open array may be assigned to an array of equal base type" the phrase "an array of equal base type" can be interpreted as either a "closed" array or an open array.
The general rule is: An array may be assigned to an array of equal base type and equal length.
There are four variations of possible exceptions to this rule that do not include the equal length requirement:
1. An open array may be assigned to an array of equal base type.
2. An array may be assigned to an open array of equal base type.
3. An array may be assigned to an array of equal base type.
4. An open array may be assigned to an open array of equal base type.
Only (1) has been identified as an allowable exception, so the conclusion is that (2), (3) and (4) are not allowed.
Re: Oberon Report Update 2016-05-01
Only if the arrays have the same type.cfbsoftware wrote: The general rule is: An array may be assigned to an array of equal base type and equal length.
By allowing strings to be assigned to (variable parameter) open character arrays we introduce a new kind of run-time error which occurs when the length of the destination array is too small. Once we have opened the possibility for such a run-time error I see no reason why we would allow 1 but not 2 and 4.Variation 3 is out of the question unless the arrays have been declared with the same type.cfbsoftware wrote: There are four variations of possible exceptions to this rule that do not include the equal length requirement:
1. An open array may be assigned to an array of equal base type.
2. An array may be assigned to an open array of equal base type.
3. An array may be assigned to an array of equal base type.
4. An open array may be assigned to an open array of equal base type.
Re: Oberon Report Update 2016-05-01
If I understand it correctly, Wirth's own compiler only causes program abortion if the source array is longer than the destination array. As with strings, assigning a shorter array to a longer is accepted.augustk wrote:3. Open arrays can be assigned to arrays with the same base type.