Plan for D
IGotD-
nise at nise.com
Thu May 20 18:11:14 UTC 2021
On Thursday, 20 May 2021 at 17:52:11 UTC, Ola Fosheim Grostad
wrote:
>
> How does Nim deal with references to array elements and struct
> fields? Does it use fat pointers?
Yes, Nim has fat pointers denoted by the "ref" keyword which
means that it is GC allocated.
https://nim-lang.org/docs/manual.html
*References (similar to pointers in other programming languages)
are a way to introduce many-to-one relationships. This means
different references can point to and modify the same location in
memory (also called aliasing).*
*Nim distinguishes between traced and untraced references.
Untraced references are also called pointers. Traced references
point to objects of a garbage-collected heap, untraced references
point to manually allocated objects or objects somewhere else in
memory. Thus untraced references are unsafe. However, for certain
low-level operations (accessing the hardware) untraced references
are unavoidable.*
*Traced references are declared with the ref keyword, untraced
references are declared with the ptr keyword. In general, a ptr T
is implicitly convertible to the pointer type.*
More information about the Digitalmars-d
mailing list