[Oberon] Procedure variables and local procedures
Jörg
joerg.straube at iaeth.ch
Sat Sep 30 17:03:53 CEST 2017
chris
> TYPE
> CharPtr = POINTER TO ARRAY OF CHAR;
> VAR
> p : CharPtr;
> BEGIN
> NEW(p, 1234);
Ah I see, you are referring to Oberon-2 (1993) http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.37.9417&rep=rep1&type=pdf <http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.37.9417&rep=rep1&type=pdf>
NW designed two languages:
- the original Oberon https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon.Report.pdf <https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon.Report.pdf> (1990)
- and his revision Oberon-07 https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf <https://www.inf.ethz.ch/personal/wirth/Oberon/Oberon07.Report.pdf> (2013/16)
In the original Oberon, NW defined in the low level compiler module SYSTEM the procedure NEW(v, n).
In Oberon-07 this is not existing anymore. As Andreas Pickelbauer demonstrated, this functionality can be introduced with Oberon-07 without changing the language. I mean: it is not necessary to introduce NEW(p, n) in the Oberon-07 language as base construct as all means to do so are there already. Okay, I have to admit that you need to know how the OS implements memory management and garbage collection but this has nothing to do with the language.
> Leaving this undefined in the language report makes the type BYTE an
> unusable feature for portable programs.
Whether the index i of the expression a[i] shall be checked is not defined in Oberon either. This is left to the implementation as you might want your code to be finetuned for speed (no checks) or security (with checks). Oberon-07 offers different methods for your concern:
ASSERT( (0 <= i) & (i <= 255) ); b := i; or
b := i MOD 256;
I find BYTE quite useful. In the original Oberon, the comparable SHORTINT was signed, BYTE is unsigned. When e.g. parsing TCP packets and you wanted to calculate the port nbr, you couldn’t easily use SHORTINT. So, I often misused CHAR, as ORD(c) returns an unsigned value. As in the majority of cases bytes are treated unsigned, BYTEs makes the code a little bit more intuitive to read.
br
Jörg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20170930/452b360b/attachment.html>
More information about the Oberon
mailing list