pointer


Computer Memory

Computer memory is a large, linear sequence of addressable storage locations used to store data and instructions while a program is running.

Memory Address

A memory address is a number that identifies a specific location in computer memory. Each address corresponds to a byte (or a small group of bytes), and can be used to read or write data stored at that location.

Pointer

A pointer is a s64 that holds a memory address. A pointer is usually pointing to a value of a specific type; if it is pointing to a value with type T, then the type of the pointer is *T.

Pointer Dereference

Given a pointer p : *T, then p.* can do different things, depending on the context it is used in:

  1. Read: p.* yields the value stored at the memory address p
  2. Write: p.* yields a reference to the underlying memory, allowing you to change what is stored at the memory address p