Documentation#Pass-by-value Parameters states:
Structs, unions, and arrays can sometimes be more efficiently passed as a reference, since a copy could be arbitrarily expensive depending on the size. When these types are passed as parameters, Zig may choose to copy and pass by value, or pass by reference, whichever way Zig decides will be faster. This is made possible, in part, by the fact that parameters are immutable.
The closing comment on GitHub issue #5973 however, implies this is no longer the case. I couldn't find the actual behavior or change notes about this, and would be nice to know what is possible for the code to actually do.
The docs should be updated to reflect these changes in the language, as it can lead to people: 1. copying huge structs into functions thinking the compiler will optimize it away; and 2. being needlessly scared of aliasing where it can't happen anymore :P
[Documentation#Pass-by-value Parameters](https://ziglang.org/documentation/0.16.0/#toc-Pass-by-value-Parameters) states:
> Structs, unions, and arrays can sometimes be more efficiently passed as a reference, since a copy could be arbitrarily expensive depending on the size. When these types are passed as parameters, Zig may choose to copy and pass by value, or pass by reference, whichever way Zig decides will be faster. This is made possible, in part, by the fact that parameters are immutable.
[The closing comment on GitHub issue #5973](https://github.com/ziglang/zig/issues/5973#issuecomment-4334852241) however, implies this is no longer the case. I couldn't find the actual behavior or change notes about this, and would be nice to know what is possible for the code to actually do.
The docs should be updated to reflect these changes in the language, as it can lead to people: 1. copying huge structs into functions thinking the compiler will optimize it away; and 2. being needlessly scared of aliasing where it can't happen anymore :P