I've heard borrowing
parameters described as const T&
or const T*
as analogies to C/C++.
I'm trying to understand which it actual is, or more to the point when an extra pointer might get involved, that wouldn't be there otherwise (vs an unadorned parameter).
I can see from the compiler's output that at least for trivial types (e.g. Int
) borrowing
/ consuming
have absolutely no effect on the parameter (nor the code inside the function) - it's still passed in a register (or spilled onto the stack), i.e. by value.
Is that always the case, for value types; the calling convention is unchanged?
And for reference types, where the value passed in a register is a pointer, is it similarly always the case that the borrowing
/ consuming
version is still just that same pointer? As opposed to a pointer to that pointer?
I mean, the answer seems like it should be really obviously "yes" to both questions, but, I just want to check. Value types can get really complicated.