Each parameter in a method call obeys the following syntax
[ (modifier) ] (mode) (type) (name)
Where (mode) is one of in,
out, or inout; (type) is
any SIDL recognized type; and (name) is
any non-reserved word6.2.
The (modifier) is optional, and currently
unimplemented. SIDL currently reserves the word
copy for future use as an parameter modifier,
and may add others in the future6.3.
For new users, the parameter's mode (e.g. in,
out, or inout) is perhaps the most troublesome.
On the surface, it's easy to explain that in parameters
are passed into the code, out parameters come out,
and inout parameters do both. More specifically the rules are:
- in does not mean const.
- in arguments are passed by value, therefore what happens
inside the function has no effect on the value passed in (from the
perspective of the caller).
- inout arguments are passed by reference. The callee is
allowed to do whatever it wants with the data passed in,
and changes made by the callee are sent back to the caller.
For interfaces, classes, and normal arrays, the callee
can even destroy the reference, create a new object or
array, and return a reference to it.
- Objects, interfaces and arrays should be allocated using the
create methods provided. Types created on the stack should never be
passed as an inout argument, since the implementation
may want to destroy it.
- out arguments are also passed by reference, but the
incoming value is ignore and typically overwritten.
Do Not attempt to
pass in a value to a function through an out argument. There is no
guarantee that the data will make it to the Implementation, and if the
data is lost, there is no guarantee the reference will be correctly destroyed.
babel-0.10.2
users_guide Last Modified 2005-03-23
http://www.llnl.gov/CASC/components
components@llnl.gov