Issue 16269: Inconsistencies related to use of const& (dds-psm-cxx-ftf) Source: Remedy IT (Mr. Johnny Willemsen, jwillemsen(at)remedy.nl) Nature: Clarification Severity: Minor Summary: There is consistency issue in the spec with respect to the use of const & versus returning copies. Resolution: Revised Text: Actions taken: May 26, 2011: received issue Discussion: End of Annotations:===== m: webmaster@omg.org Date: 26 May 2011 08:56:01 -0400 To: Subject: Issue/Bug Report ******************************************************************************* Name: Johnny Willemsen Employer: Remedy IT mailFrom: jwillemsen@remedy.nl Terms_Agreement: Specification: ISO/IEC C++ 2003 Language DDS PSM Section: - FormalNumber: 07-01-01 Version: Beta 1 Doc_Year: 2011 Doc_Month: January Doc_Day: 01 Page: - Title: Inconsistencies related to use of const& Nature: Clarification Severity: Minor CODE: 3TMw8 B1: Report Issue Description: From: Richard Warren To: Johnny Willemsen CC: "dds-psm-cxx-ftf@omg.org" Date: Thu, 26 May 2011 09:08:57 -0700 Subject: Re: issue 16269 -- ISO/IEC C++ DDS PSM FTF issue Thread-Topic: issue 16269 -- ISO/IEC C++ DDS PSM FTF issue Thread-Index: AcwbvziVWP4mdc2lTCurQs+MCO77Iw== Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US X-MIME-Autoconverted: from quoted-printable to 8bit by amethyst.omg.org id p4QG30Be024256 Johnny, FYI, the intended convention in the PSM when returning collections is to always provide 2 overloads: 1. Return by const value. 2. Accept non-const reference as input; fill in that object, then return a non-const reference to it in order to facilitate chaining. Strings are assumed to be cheaper then vectors, so #2 is omitted. This approach was selected because it is memory safe, thread safe, does not constrain implementations, and prevents accidental modifications to temporary objects. Overload #2 also provides callers a way to avoid some of the allocation-related expenses of returning by value. When you say the spec is inconsistent, can you be more specific about where you are seeing this convention violated? Are you referring to the DDS API itself, to the language binding, or to an inconsistency between the two? Thanks for clarifying, - Rick -- Rick Warren Director of Technology Solutions RTI Tel 408.990.7455 rick.warren@rti.com www.rti.com RTI - The Global Leader in DDS On May 26, 2011, at 9:00 AM, Juergen Boldt wrote: >> Name: Johnny Willemsen >> Employer: Remedy IT >> mailFrom: jwillemsen@remedy.nl >> Terms_Agreement: >> Specification: ISO/IEC C++ 2003 Language DDS PSM >> Section: - >> FormalNumber: 07-01-01 >> Version: Beta 1 >> Doc_Year: 2011 >> Doc_Month: January >> Doc_Day: 01 >> Page: - >> Title: Inconsistencies related to use of const& >> Nature: Clarification >> Severity: Minor >> CODE: 3TMw8 >> B1: Report Issue >> >> Description: >> >> There is consistency issue in the spec with respect to the use of const & versus returning copies. X-Virus-Scanned: by XS4ALL Virus Scanner Date: Fri, 27 May 2011 11:11:25 +0200 From: Johnny Willemsen Reply-To: jwillemsen@remedy.nl Organization: Remedy IT User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110414 SUSE/3.1.10 Thunderbird/3.1.10 To: Richard Warren CC: "dds-psm-cxx-ftf@omg.org" Subject: Re: issue 16269 -- ISO/IEC C++ DDS PSM FTF issue Hi, I filled this issue because Angelo made a remark he agreed there where inconsistencies. Maybe it could help when someone creates some more examples with some more complex IDL types than just the 1 in the specification. Do some level of nesting of structs, and add some regular sequences, and than show the user code if someone wants to change data in the structure (including some information on the amount of copying that he will get). Johnny On 05/26/2011 06:08 PM, Richard Warren wrote: > Johnny, > FYI, the intended convention in the PSM when returning collections is to always provide 2 overloads: > > 1. Return by const value. > > 2. Accept non-const reference as input; fill in that object, then return a non-const reference to it in order to facilitate chaining. > > Strings are assumed to be cheaper then vectors, so #2 is omitted. > > This approach was selected because it is memory safe, thread safe, does not constrain implementations, and prevents accidental modifications to temporary objects. Overload #2 also provides callers a way to avoid some of the allocation-related expenses of returning by value. > > When you say the spec is inconsistent, can you be more specific about where you are seeing this convention violated? Are you referring to the DDS API itself, to the language binding, or to an inconsistency between the two? > > > Thanks for clarifying, > - Rick > > > -- > Rick Warren > Director of Technology Solutions > RTI > Tel 408.990.7455 > rick.warren@rti.com > www.rti.com > > RTI - The Global Leader in DDS > > On May 26, 2011, at 9:00 AM, Juergen Boldt wrote: >>> Name: Johnny Willemsen >>> Employer: Remedy IT >>> mailFrom: jwillemsen@remedy.nl >>> Terms_Agreement: >>> Specification: ISO/IEC C++ 2003 Language DDS PSM >>> Section: - >>> FormalNumber: 07-01-01 >>> Version: Beta 1 >>> Doc_Year: 2011 >>> Doc_Month: January >>> Doc_Day: 01 >>> Page: - >>> Title: Inconsistencies related to use of const& >>> Nature: Clarification >>> Severity: Minor >>> CODE: 3TMw8 >>> B1: Report Issue >>> >>> Description: >>> >>> There is consistency issue in the spec with respect to the use of const & versus returning copies. > > There is consistency issue in the spec with respect to the use of const & versus returning copies.