spekyuman wrote:
[..] This is where the heart of my question lies:
[1] Sending data by value to a procedure requires data to be copied
from the caller to the routine.
From the factual argument into the formal argument. Or, simply put,
the local variable of the function has to be initialised with the same
value (copy-initialised, of course).
[2] Sending a pointer to a procedure requires data to be copied from
the caller to the routine. Specifically, the pointer address
The pointer address?
is sent
by value and reports a size of 4-8 bytes on modern systems; only the
object data is being passed by reference.
The pointer is passed by value: the local variable is initialised with
the value of the pointer that the caller supplies as the argument.
Nothing else is passed by no other method.
[3] My question is, what exactly happens with a reference type during
a procedure call?
The reference (the local variable of the function) is initialised by
the l-value passed to it by the caller.
Is there any overhead? What are the mechanisms at
work?
Some implementation-defined mechanisms. How references are implemented
and what (if any) overhead there can be observed, is not specified by
the language. If you'd like to discuss a particular implementation,
you're welcome to, just not here.
Initialising a reference argument (an argument that has a reference
type) is no different than initialising one without the interference
of a function call/invocation.
Object someObject;
Object & rObject = someObject;
what mechanisms are at work? Is there overhead? Implementation-defined.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask