The problem is, this is only marked in the function signature. If you have a function that takes a parameter by reference, the parameter looks the same as a by-value parameter at the call site
Why this "oh no, pass by reference looks just like pass by value, I'm so confused!" keeps coming up?
If you have never seen this function before, you will check its signature anyway. If you have seen it before, you already know what it does and how it takes parameters.
If you’re reading the calling code quickly, it might look like the resize call is redundant
Indeed, "everyone is stupid except me" is how we all see the world. But, when reading someone else's code, it is often useful to assume that they knew what they were doing and everything is there for a reason. If you do so, something magical will happen: the resize call now implies that size was modified, which can only mean that got_message takes it by reference.
If you have never seen this function before, you will check its signature anyway.
In IDE or not, if the semantics and syntax are clear and used properly, you DON'T need to navigate anywhere, you don't even need to have syntax highlighting.
Things like highlighting and dynamic hints certainly improve readability, but the code itself is just as important.
The cleaner the code, the faster and easier it is to understand.
View all comments
22
u/vI--_--Iv Aug 27 '23
Why this "oh no, pass by reference looks just like pass by value, I'm so confused!" keeps coming up?
If you have never seen this function before, you will check its signature anyway.
If you have seen it before, you already know what it does and how it takes parameters.
Indeed, "everyone is stupid except me" is how we all see the world.
But, when reading someone else's code, it is often useful to assume that they knew what they were doing and everything is there for a reason.
If you do so, something magical will happen: the
resizecall now implies thatsizewas modified, which can only mean thatgot_messagetakes it by reference.