Issue 15010: Collection::sum is not realisable for empty collection of user defined type (ocl2-rtf) Source: Model Driven Solutions (Dr. Edward Willink, ed(at)willink.me.uk) Nature: Uncategorized Issue Severity: Summary: Collection::sum is defined to exploit an associative and commutative T::+(T). However for an empty collection, the result must be a zero value of the user defined type and there is no mechanism to determine its 0. Suggest: require a T::zero() and provide corresponding Real::zero() and Integer::zero() and UnlimitedNatural() operations. Resolution: deferred Revised Text: Actions taken: January 31, 2010: received issue Discussion: Revised Text: (DO NOT APPLY REVISION SINCE FINAL DISPOSITION IS DEFERRED) In 11.4.1 Real add oclZero : Real The additive identity. init: 0.0 oclOne : Real The multiplicative identity. init: 1.0 100 In 11.4.2 Integer add oclZero : Integer The additive identity. init: 0 oclOne : Integer The multiplicative identity. init: 1 In 11.4.3 String add oclZero : String The additive identity. init: '' In 11.5.? UnlimitedNatural add oclZero : UnlimitedNatural The additive identity. init: 0 oclOne : UnlimitedNatural The multiplicative identity. init: 1 In 11.6.1 sum() replace Elements must be of a type supporting the + operation. … Integer and Real fulfill this condition. post: result = self->iterate( elem; acc : T = 0 | acc + elem ) by Elements must be of a type supporting the + operation and the oclZero property. … The oclZero property provides the additive identity. UnlimitedNatural, Integer, Real and String fulfill this condition. post: result = self->iterate( elem; acc : T = T::oclZero | acc + elem ) Disposition: DEFERRED NOTE: The vote did not passed for this issue (initial disposition was Resolved). 101 Reason : Issue 15010 uses redefined properties with covariant types. Once the Standard Library is aligned with UML, this usage will not be allowed End of Annotations:===== ronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsYEAD/XZEtUXebq/2dsb2JhbACTPsJLhEUE Date: Sun, 31 Jan 2010 09:05:58 +0000 From: Ed Willink User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1.5) Gecko/20091204 Thunderbird/3.0 To: issues@omg.org Subject: OCL 2.1 Collection::sum is not realisable for empty collection of user defined type X-Plusnet-Relay: 3ad7af1c63c520fb221f150855e7a229 Hi Collection::sum is defined to exploit an associative and commutative T::+(T). However for an empty collection, the result must be a zero value of the user defined type and there is no mechanism to determine its 0. Suggest: require a T::zero() and provide corresponding Real::zero() and Integer::zero() and UnlimitedNatural() operations. Regards Ed Willink