A pointer is a low-level reference to the in-memory address to data. Pointers can be un-typed (so-called Void pointers) to generically refer to a location in memory, or they can be typed and (ostensibly) refer to the location of a specific data type at that memory location.
In the latter case, a pointer can be dereferenced and used as if it were the underlying type.
A pointer is expressed by using the
^ character, followed by a type name. For un-typed pointers, the
Void type name is used, as in
var a: Integer; // a regular Integer var b: ^Integer; // pointer *to* an Integer
The Address Of (
@) Operator can be used to get the address of an item as a pointer:
a := 15; // set a to 15 b := @a; // make `b` a pointer to the address of `a`
A pointer can be dereferenced in order to get back to the value it points to, by appending the Pointer Dereference (
^) Post-Fix Operator to it. The result is an expression that can be used interchangeably with the underlying type of the pointer – for example, a deference
^Integer could be used in expressions like any other Integer.
var x := a + b^ b^ := 12; // also changes `a`!
Note that pointers are not supported on the [Java] Platform (/Platforms/Java) at all.
On .NET, pointers are available in a limited fashion, but they are considered "unsafe". In order to use them, the "Allow Unsafe Code" Compiler Option must be enabled, and any Methods that deal with pointers must be marked with the
unsafe Member Modifier.