Subject: [sv-ec] Pass by reference
From: Neil Korpusik (Neil.Korpusik@eng.sun.com)
Date: Thu Feb 13 2003 - 13:50:33 PST
Section 10.5.2, "Pass by reference", needs more explanation.
The semantics for the various data types needs to be explained in more detail.
I have tried to summarize my current understanding below for a couple of data
types. This is the level of detail we should have in the LRM.
unpacked arrays - a reference is passed as opposed to the contents of the array
- modifications made to the array contents by the callee are
visible to the caller.
- the memory referenced can't be changed by the callee. In
other words the same unpacked array will be used by the
caller although the contents of that array may have been
modified by the callee.
object handles - a reference to the handle is passed.
- the callee can modify the state of the referenced object
(this is true no matter what "direction" has been specified).
- the callee can modify the handle such that it now refers to
a different object. This change is reflected in the caller.
The object handle in the caller now refers to this new
object.
It appears that a 'ref' parameter behaves like an 'inout' parameter except
for the fact that the contents of the data item aren't copied into the
subroutine when using 'ref'. From a user perspective there doesn't appear to
be any difference between an inout object handle and a ref object handle.
Section 3.12, second paragraph, last sentence says, "Classes can also be passed
around by reference via handles, adding a safe-pointer capability".
This could be misconstrued to imply that object handles can only be passed to a
subroutine when using 'ref' parameters. This is not the case. An object
handle can be declared to be: input, output, inout or ref.
Section 10.3 and 10.2
We may need to get clarification from the BC committee on "output". Does this
imply that a parameter passed to a subroutine using the "output" directionality
has an undefined value upon entry to that subroutine?
Neil
This archive was generated by hypermail 2b28 : Thu Feb 13 2003 - 13:51:14 PST