Brain Dump

Pointers

Tags
comp-arch

Are values that point to addresses in memory and act as a way to implement pass-by-reference for languages such as C.

Ordinarily when we call a function a new stack frame is created where the values of all our arguments are copied in. If we pass a pointer the pointer itself is copied but we can dereference the pointer to access and modify the value the pointer references.

Note: Java is a classic example of a language in which everything is pass by value. User defined types are implicitly passed by references, but those reference values are what's actually passed. Re-assigning the reference passed to a function doesn't update the value passed by reference, it simply allocates a new one somewhere else.