Good Old Pointers (2015)
6 points by icefox
6 points by icefox
Even when a parameter is a large compound value, the programmer shouldn’t be forced to optimise the call by passing an ‘immutable reference’ instead. The compiler (and the ABI specification) can handle this.
This is super convenient and how Ada works: Immutable (in) parameters by default, or modifiable in out or write-only out. What actually happens? Mostly compiler's choice, but you're not allowed to store addresses to these parameters unless you explicitly mark them as aliased. There's some caveats, but it describes intent and avoids a lot of explicit pointers or references. You can explicitly pass around pointers if you really want, but those things are heap allocated or marked as aliased somewhere higher in the call chain.