There are any number of ways to skin that cat. In Rust, for example, values you pass, whether by value or by reference, are immutable by default. You have to explicitly mark them as mutable in the receiving function signature to allow mutation. I freaking love that as a default. Passing by reference is trivially easy, but you still avoid accidentally altering things that ought not be frobnicated.

In this case it might interest you to learn that in Raku (Perl 6), the values passed to a function are also by default immutable within that function.

If one wants the function to mutate them, one has to explicitly mark them as `$x is rw` in the function signature; this then requires one to always pass a mutable container for $x. (A bit more detail: https://andrewshitov.com/2019/10/15/110-is-rw-vs-is-raw-in-r... )

That's a nice improvement, to be sure!