-----Original Message----- From: Chris Burrows [mailto:chris at cfbsoftware.com] on Sunday, 1 October 2017 9:52 AM
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 Pirklbauer demonstrated, this functionality can be introduced with Oberon-07 > without changing the language.
Not exactly. Oberon-07 doesn't allow ARRAY OF <type> in a type or variable declaration (excluding open array parameters which are a different concept). Nor does Oberon-07 allow POINTER TO ARRAY - pointers can only point to RECORDS (which can have ARRAYs as fields). If these syntax changes were introduced they would need to be considered as language extensions. There would also be the question of whether the feature would be restricted to single-dimensional arrays, what notation would be used if multi-dimensional arrays would be used, how many dimensions would be allowed, what are the rules of assignment compatibility issues etc. I have seen various Oberon-style implementations of this over the years e.g.
It would be fairly easy to add any of the features mentioned above (e.g. POINTER TO ARRAY, multi-dimensional arrays) to the solution outlined in http://www.github.com/andreaspirklbauer/Oberon-generic-heap-allocation , but that is the one thing I did *not* want to do: extend the language itself. It can of course be done, but one should note that one can always just create a record that then contains any data structure one needs. The downside is that it introduces one additional field in the code, e.g. you write ptr.a[3] instead of ptr[3], where ptr is a POINTER TO R, and R is a RECORD a: ARRAY OF <type> END, making it a little less natural to read. Just my two (Swiss) Rappen.. -AP