Pointers

Spice supports pointers with by providing the referencing operator & and the de-referencing operator *.
For any primitive and custom data type you can also use the respective pointer type. For the int type, the pointer type is int*.

See an example here:

int variable = 1234;
int* variablePtr = &variable;
printf("Value: %d, Pointer: %p", *variablePtr, variablePtr);

Here is a more complex example where pointers are used to pass a reference of a person to a procedure and modify a field.

type Person struct {
    string firstName
    string lastName
    int age
}

p birthday(Person* person) {
    *person.age++;
}

f<int> main() {
    dyn mike = new Person { "Mike", "Miller", 32 };
    printf("Age before birthday: %d", mike.age);
    birthday(&mike);
    printf("Age after birthday: %d", mike.age);
}