Parameter Passing

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:

  1. in does not mean const.
  2. 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).
  3. inout arguments are passed by reference. The callee is allowed to do whatever it wants with the data passed in, even destroy the reference and return a new one.
  4. Types created on the stack should never be passed as an inout argument, since the implementation may want to destroy it.
  5. out arguments are also passed by reference, but they are assumed NULL when they are passed in. 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.9.6
users_guide Last Modified 2004-09-08

http://www.llnl.gov/CASC/components
components@llnl.gov