In Scopes, the let
keyword is an immutable binding to a name. Sometimes we call them register variables, which is an LLVM-ism. Because it's just a binding with no location in memory and a completely abstract construct, you can alias things that aren't necessarily values, like types or keywords. You can bind anything to a valid symbol; you could even shadow let
itself.
You can mutate 3 different types of values in Scopes: stack variables, global state variables and mutable pointers.
- Stack variables are declared with the
local
keyword. They expire when you exit the function frame (ie. return). - Global state variables are declared with the
global
keyword. Their memory location is static and always available. It's always safe to take a pointer to global data (although it might not be to do so from multiple threads). - Pointers are addresses to a memory location. You can take the address from a local, global or through memory allocati