3 ms·
When the compiler can see both the callee and the caller (the most common case), why should it even matter? If you pass by value, but don't actually do anything
by int_19h 4y ago
When the compiler can see both the callee and the caller (the most common case), why should it even matter? If you pass by value, but don't actually do anything that mutates the copy, and there are no aliasing concerns, surely the compiler can make it by-ref under the hood?
(The other direction is trickier, since by-ref implies the desire to observe aliasing, even though that's usually not expected in practice - but the compiler cannot tell.)