[Oberon] Dynamic array allocation?

Till Oliver Knoll till.oliver.knoll at gmail.com
Tue Apr 9 21:38:20 CEST 2019



Am 09.04.2019 um 09:26 schrieb Jörg Straube:
> Oliver
> 
> Oberon-07 does not offer a language construct to allocate arrays on the heap.
> 
> This said, there are ways around it, if you need it.
> Workaround 1:
[...]
> Workaround 5:
> The heap allocation is basically a procedure in Kernel. If you use the language construct NEW(), the compiler generates a call to Kernel.New. If you are very savvy in low level programming and know the mechanisms the garbage collector uses, you might add a new procedure to Kernel to allocate a memory block of variable length.
> Instead of NEW(p, 200) you would then call Kernel.DynaNew(p, 200).
> But as I said you have to fully understand the current mechanisms of Kernel.New() and Oberon.GC to do so.
> 
> Workaround 6:
> Take Andreas system and compiler. He implemented wirkaround 5 and extended Oberon-07 with a new language construct.

Hello Jörg,

Thanks a lot for your answer! I'll certainly have a look at your many
example workarounds you gave.

Yes, my use case would indeed more focus on the "dynamic aspect", not so
much on the question "stack vs heap" (even though "dynamic" pretty much
implies "heap", of course). Specifically I had a simple "image loader"
(bitmap BPM format) in mind which would load black and white bitmap data
into memory and create "patterns" out of it.

Your comments and examples pretty much confirm what I had already
anticipated. I understand that all those extensions (dynamic array
allocation, numeric case, and more) are already implemented in e.g.
"Experimental Oberon", but for now I try to stick "with the basics",
such that my silly example draw application compiles "out of the box" on
the most common "Project Oberon 2013" implementations - for now (given
the very limited audience it probably does not matter too much anyway ;)).

Maye I take option 6) and put it into my "application code" (checked
into Git), I already had a quick look at its implementation, the "NEW
extension" is also available as an "add-on" for PO 2013 (compiles on
that Oberon version).


Thanks a lot again,
  Oliver


More information about the Oberon mailing list