A pointer type (*T) is similar to a reference type, with the exception that it allows for pointer arithmetic (offset). An example API would look like:
// Retrieves the value that this pointer refers to.
public func <T> *T.read() -> T;
// Sets the value within this pointer to a value (`@ptr = value`).
public func <T> *T.set(value: T);
// Returns a new pointer, which has been offset by `count` units of `T`.
public func <T> *T.offset(count: i64) -> This;
Some questions that still need to be answered:
- Should
read return an optional?
- How can a pointer be casted to another type?
- Is there anything that can be done to ensure that the caller calls
memory::free on a pointer?
A pointer type (
*T) is similar to a reference type, with the exception that it allows for pointer arithmetic (offset). An example API would look like:Some questions that still need to be answered:
readreturn an optional?memory::freeon a pointer?