CORBA IDL in, out and inout
Asked Answered
C

1

7

What exactly do in, out and inout - 'directional' operators mean in CORBA IDL function parameters?

Cacophonous answered 7/6, 2011 at 11:20 Comment(0)
D
10

From Ciaran McHale's free online book, CORBA Explained Simply:

The parameters of an operation have a specified direction, which can be in (meaning that the parameter is passed from the client to the server), out (the parameter is passed from the server back to the client) or inout (the parameter is passed in both directions).

So an in parameter is very similar to "traditional" function parameters in that the caller must pass a value for them and that value is used by the server to do its work.

An out parameter is just like a return value, so the caller never populates it with a value. It just magically has a value when the function returns (assuming an exception wasn't thrown) because the server is responsible for putting a value inside it as part of its execution rules. You can have as many out parameters as you want, allowing you to return multiple distinct objects or values without having to first combine them into a struct.

An inout parameter combines the two concepts above. The caller must populate all inout parameters with valid data but those values may be different after the function returns because the server is free to put new data in there.

Dierolf answered 7/6, 2011 at 14:29 Comment(5)
So, can I say this way : in = pass by value. out = pass reference. inout = pass by reference ?Cacophonous
That's an OK way to start thinking about it, but that analogy can get confusing when you start dealing with CORBA types like Object References. You can pass these as in parameters, so that would be a pass by reference by value :) You can hopefully see where that could get confusing! But yes, that analogy isn't the worst place to start because it relates fairly well to most people's expectations about parameter passing.Dierolf
in = pass by value, inout = pass by reference, out = something unique to CORBA (pass uninitialized variable by reference). If you specify your parameter to be out, then the parameter you specify in a call can't be read in the called function... because CORBA will explicitly pass uninitialized junk in its stead. So with out parameters, you can only assign to the parameter, not read.Splasher
What is the point of out if CORBA methods already have a return type?Gurglet
You can only return one value, but you can have as many out values as you'd like.Dierolf

© 2022 - 2024 — McMap. All rights reserved.