[Oberon] Realloc function and simulating continue and break in Oberon-07 loops
Chris Burrows
cfbsoftware at gmail.com
Thu Oct 20 23:08:12 CEST 2022
On Fri, Oct 21, 2022 at 5:45 AM Deadmarshal <adeadmarshal at gmail.com> wrote:
>
> I was also wondering if a realloc() function similar to C can be made in
> Oberon? Because it can be used to create dynamic arrays much like the CPP's
> std::vector. I am well aware that I could use a linked list for that
> purpose, but I'm curious about dynamic arrays.
>
A similar capability has been implemented in Gardens Point Component Pascal
(i.e. Oberon-2+ for .NET and JVM). Refer to Section 4.6 "Extensible arrays:
the vector type" in the release notes:
"Values of these vector types are dynamically allocated, and automatically
extend their capacity when an append operation is performed on an array
that is already full. Vectors may be
declared to have any element type, and extend their length using amortized
doubling. In most circumstances when a linked list would otherwise have
been used the vector
types are faster, more memory efficient, and allow memory-safe indexing.
Elements of vectors may be accessed using the familiar index syntax, with
index values checked against the active length of the array, rather than
the array capacity."
https://github.com/k-john-gough/gpcp/releases
Full source code is available if you want to see how you might implement a
similar extension in your preferred Oberon system.
Regards,
Chris Burrows
CFB Software
https://www.astrobe.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.inf.ethz.ch/pipermail/oberon/attachments/20221021/c8de85fd/attachment.html>
More information about the Oberon
mailing list