Issue 4150: Optional parameters for _create_request? (cxx_revision) Source: Triodia Technologies Pty Ltd (Mr. Michi Henning, michi(at)triodia.com) Nature: Uncategorized Issue Severity: Summary: On page 1-119, the spec says the following about _create_request() and _create_request2(): [...] the ORB requires: - a target object reference - an operation name - a list of arguments (optional) ^^^^^^^^^^ - a place to put the result (optional) ^^^^^^^^^^ - a place to put any returned exceptions - a Context (optional) ^^^^^^^^^^ - a list of the user-defined exceptions that can be thrown (optional) ^^^^^^^^^^ - a list of Context strings that must be sent with the operation (optional) ^^^^^^^^^^ Note all the "optional" remarks. It's not clear what "optional" actually means. We have two cases for these parameters: - Arguments, user exceptions, and IDL contexts are *sequences*. - Result and context are object references. Two questions: - What does it mean for a sequence parameter to be "optional"? That I can pass a null pointer or that I can pass an empty sequence? I assume that an empty sequence is meant, but the spec doesn't say that. - What does it mean for a reference parameter to be "optional"? That I can pass a nil reference or that I must pass a reference to some dummy object that indicates that the value really isn't there? Where this is particularly annoying is for the return value. (The "result" parameter to _create_request()): - If I can pass a nil reference, no problem. This could be interpreted to mean the same thing as a void return type. - If I can't pass a nil reference, what should I pass? Obviously, it would have to be a reference to a valid NamedValue object. But how do I create that NamedValue object? I can call ORB::create_named_value(), but what should I do then? CORBA::NamedValue_var result; orb->create_named_value(result); At this point, I have a NamedValue containing an Any with tk_null (because that's what the Any default constructor creates). However, to correctly indicate that the operation I want to call has a void return type, I have to make a NamedValue that contains an Any with tk_void. But, how do I achieve that? I can't use one of the Any inserters to turn the TypeCode in the Any into tk_void, and I can't use the type() member of the Any because I can't change the type of an Any if it isn't consistent with the TypeCode that's already there... Even worse, the NamedValue doesn't seem to make sense as the return value at all. For one, it has a name attribute. - What is the value of that name for a return value? - How would I set that string after having create the NamedValue by calling create_named_value()? - What is the value of that string once I have called create_named_value()? Second, the NamedValue contains a flags attribute. - What is the value of that flags attribute for a return value? None of ARG_IN, ARG_INOUT, or ARG_OUT make sense. (One could argue that ARG_OUT could be used, but I think that sucks...) - How would I set that flag on the NamedValue I have just created? The mapping for NamedValue only offers accessor but no modifiers, so I can't set the value of the flag. - What is the value of the flag once I have called create_named_value()? It seems that the easiest way to fix the problem is to state that, if a parameter isn't needed, this is indicated by an empty sequence for lists, and by a nil reference for objects. However, the problems around create_named_value() and appear to be more serious. How should we fix those? Resolution: Revised Text: Actions taken: January 16, 2001: received issue Discussion: deferred in June 2011 to the next RTF End of Annotations:===== Date: Tue, 16 Jan 2001 11:25:12 +1000 (EST) From: Michi Henning Reply-To: C++ Revision Task Force To: C++ Revision Task Force cc: issues@omg.org Subject: Optional parameters for _create_request? Message-ID: Organization: Object Oriented Concepts MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-UIDL: ^&-!!~$#"!(>2e9j-A!! On page 1-119, the spec says the following about _create_request() and _create_request2(): [...] the ORB requires: - a target object reference - an operation name - a list of arguments (optional) ^^^^^^^^^^ - a place to put the result (optional) ^^^^^^^^^^ - a place to put any returned exceptions - a Context (optional) ^^^^^^^^^^ - a list of the user-defined exceptions that can be thrown (optional) ^^^^^^^^^^ - a list of Context strings that must be sent with the operation (optional) ^^^^^^^^^^ Note all the "optional" remarks. It's not clear what "optional" actually means. We have two cases for these parameters: - Arguments, user exceptions, and IDL contexts are *sequences*. - Result and context are object references. Two questions: - What does it mean for a sequence parameter to be "optional"? That I can pass a null pointer or that I can pass an empty sequence? I assume that an empty sequence is meant, but the spec doesn't say that. - What does it mean for a reference parameter to be "optional"? That I can pass a nil reference or that I must pass a reference to some dummy object that indicates that the value really isn't there? Where this is particularly annoying is for the return value. (The "result" parameter to _create_request()): - If I can pass a nil reference, no problem. This could be interpreted to mean the same thing as a void return type. - If I can't pass a nil reference, what should I pass? Obviously, it would have to be a reference to a valid NamedValue object. But how do I create that NamedValue object? I can call ORB::create_named_value(), but what should I do then? CORBA::NamedValue_var result; orb->create_named_value(result); At this point, I have a NamedValue containing an Any with tk_null (because that's what the Any default constructor creates). However, to correctly indicate that the operation I want to call has a void return type, I have to make a NamedValue that contains an Any with tk_void. But, how do I achieve that? I can't use one of the Any inserters to turn the TypeCode in the Any into tk_void, and I can't use the type() member of the Any because I can't change the type of an Any if it isn't consistent with the TypeCode that's already there... Even worse, the NamedValue doesn't seem to make sense as the return value at all. For one, it has a name attribute. - What is the value of that name for a return value? - How would I set that string after having create the NamedValue by calling create_named_value()? - What is the value of that string once I have called create_named_value()? Second, the NamedValue contains a flags attribute. - What is the value of that flags attribute for a return value? None of ARG_IN, ARG_INOUT, or ARG_OUT make sense. (One could argue that ARG_OUT could be used, but I think that sucks...) - How would I set that flag on the NamedValue I have just created? The mapping for NamedValue only offers accessor but no modifiers, so I can't set the value of the flag. - What is the value of the flag once I have called create_named_value()? It seems that the easiest way to fix the problem is to state that, if a parameter isn't needed, this is indicated by an empty sequence for lists, and by a nil reference for objects. However, the problems around create_named_value() and appear to be more serious. How should we fix those? Cheers, Michi. -- Michi Henning +61 7 3324 9633 Object Oriented Concepts +61 4 1118 2700 (mobile) Suite 4, 8 Martha St +61 7 3324 9799 (fax) Camp Hill 4152 michi@ooc.com.au Brisbane, AUSTRALIA http://www.ooc.com.au/staff/michi-henning.html Sender: jbiggar@corvette.floorboard.com Message-ID: <3A6503F5.9DD85255@floorboard.com> Date: Tue, 16 Jan 2001 18:31:17 -0800 From: Jonathan Biggar X-Mailer: Mozilla 4.76 [en] (X11; U; SunOS 5.6 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: C++ Revision Task Force Subject: Re: Optional parameters for _create_request? References: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: 2jS!!e#-!!#gLe9UpF!! Michi Henning wrote: > > On page 1-119, the spec says the following about _create_request() and > _create_request2(): > > [...] the ORB requires: > > - a target object reference > - an operation name > - a list of arguments (optional) > ^^^^^^^^^^ > - a place to put the result (optional) > ^^^^^^^^^^ > - a place to put any returned exceptions > - a Context (optional) > ^^^^^^^^^^ > - a list of the user-defined exceptions that can be > thrown (optional) > ^^^^^^^^^^ > - a list of Context strings that must be sent with the > operation (optional) > ^^^^^^^^^^ > > Note all the "optional" remarks. > > It's not clear what "optional" actually means. We have two cases for > these parameters: > > - Arguments, user exceptions, and IDL contexts are *sequences*. No. Check again. There are explicit NVList, ExceptionList & ContextList classes defined in the C++ mapping. Even though they behave like sequences, they are psuedo-objects instead. > - Result and context are object references. I think optional meants two things here: For the argument list, result and context, not all operations have these (although one could argue that every operation has an argument list, just that it is potentially zero length). For the ExceptionList & ContextList, they were added after the first version of create_request() was defined, so they are optional in a different sense. > Two questions: > > - What does it mean for a sequence parameter to be > "optional"? > That I can pass a null pointer or that I can pass an empty > sequence? I assume that an empty sequence is meant, but > the spec > doesn't say that. This can't happen, since these are really POs. (See above). > - What does it mean for a reference parameter to be "optional"? > That I can pass a nil reference or that I must pass a reference > to some dummy object that indicates that the value really isn't > there? Another quandry. If the optional thing isn't provided, is the ORB obliged to look it up in the IR? If it has no IR, then it must fail, so what exception should be raised? > Where this is particularly annoying is for the return value. (The > "result" parameter to _create_request()): > > - If I can pass a nil reference, no problem. This could > be interpreted to mean the same thing as a void > return type. Or that the ORB should look up the appropriate information in the IR? > - If I can't pass a nil reference, what should I pass? > Obviously, it would have to be a reference to a valid > NamedValue object. But how do I create that NamedValue > object? > > I can call ORB::create_named_value(), but what should > I do then? > > CORBA::NamedValue_var result; > orb->create_named_value(result); > > At this point, I have a NamedValue containing an Any with > tk_null (because that's what the Any default constructor > creates). However, to correctly indicate that the operation > I want to call has a void return type, I have to make a > NamedValue that contains an Any with tk_void. But, how do > I achieve that? I can't use one of the Any inserters to > turn the TypeCode in the Any into tk_void, and I can't > use the type() member of the Any because I can't change the > type of an Any if it isn't consistent with the TypeCode that's > already there... Aha! A use for Any::replace! Use: result->value()->replace(CORBA::_tc_void, 0); Actually, since the ownership of NamedValue::value() is retained, why can't you just do: *result->value() = CORBA::Any(CORBA::_tc_void, 0); Perhaps not, since you want to deprecate those things anyway. We could special case Any::type(CORBA::TypeCode_ptr) to allow tk_null & tk_void to change the type of the Any, since they have no associated values. > Even worse, the NamedValue doesn't seem to make sense as > the return value at all. For one, it has a name > attribute. > > - What is the value of that name for a return value? > > - How would I set that string after having create the > NamedValue > by calling create_named_value()? > > - What is the value of that string once I have called > create_named_value()? > > Second, the NamedValue contains a flags attribute. > > - What is the value of that flags attribute for a return > value? > None of ARG_IN, ARG_INOUT, or ARG_OUT make sense. (One > could > argue that ARG_OUT could be used, but I think that > sucks...) > > - How would I set that flag on the NamedValue I have > just created? > The mapping for NamedValue only offers accessor but no > modifiers, so I can't set the value of the flag. > > - What is the value of the flag once I have called > create_named_value()? The implementation should just ignore the name and flags fields. > It seems that the easiest way to fix the problem is to state that, if a > parameter isn't needed, this is indicated by an empty sequence for lists, > and by a nil reference for objects. > > However, the problems around create_named_value() and appear to be more > serious. How should we fix those? If we were to do it right, we'd just use an Any for the result. But it's too late for that. -- Jon Biggar Floorboard Software jon@floorboard.com jon@biggar.org