Hi Alex
In further discussion on the OCL list with Nicolas Rouquette, we agreed
that operations such as count operate pair-wise and perform an
independent type-widening for each pair to locate the appropriate
XXX::= overload.
Thus Sequence{3,
3.0}->count(3.0) = 2.
Also Sequence{3,
3.0}->count(3) = 2.
Also Sequence{3,
3.0}->count(-(-3)) = 2.
[And Sequence{3,
3.0}->count(ComplexNumber(3.0,0.0)) = 2.
given a suitable user definition of the ComplexNumber type and
implementation of the pending OCL type constructor issue.]
This then strongly implies that OCL does have dynamic overload
resolution similar to Java; another issue awaiting an official issue
number. The ReflectiveLibrary as a UML-independent model can specify
this semantic in association with its conforms relationship.
Regards
Ed
On 19/01/2010 17:26, Alexander Igdalov wrote:
Hi Ed,
I fully agree with your issue
14918. However, it doesn't clearly suggest whether 1 and 1.0 should be
equal. IMO it is important to state whether numeric types are to be
coerced when compared.
If they
are then `Sequence{3,
3.0}->count(3.0) = 1.` becomes incorrect (must be 2).
Cheers,
- Alex.
Hi
I've just appended the attached to OMG Issue 14918.
Any opinions on whether
Set{ 3.oclAsType(UnlimitedNatural), 3.oclAsType(Integer),
3.oclAsType(Real) }->size() = 1.
Sequence{3, 3.0}->count(3.0) = 1.
is the interpretation that we want?
Certainly not quite what I would have expected, but anything else seems
much worse.
Ed
-------- Original Message --------
Hi
The problem of value object identity is much more widespread.
All the collection operations such as count(), includes() etc are based
on objects, so it is unclear whether
Set{ 3.oclAsType(UnlimitedNatural), 3.oclAsType(Integer),
3.oclAsType(Real) }->size() is 1, 2 or 3.
and whether
Sequence{3, 3.0}->count(3.0) is 1 or 2.
For 3.oclAsType(UnlimitedNatural) and 3.oclAsType(Integer) to be
different 'objects' would be very confusing,
so 3.oclAsType(Integer) and 3.oclAsType(Real) must be the same 'object'
too.
It is presumably sufficient to specify that each distinct numeric value
is notionally represented by a singleton value object of the narrowest
possible PrimitiveType. Thus 3 and 3.0 are both represented by the
3.oclAsType(UnlimitedNatural) singleton. Implementations may use
multiple non-singleton value objects, but these may not be observably
distinct.
Therefore:
Set{ 3.oclAsType(UnlimitedNatural), 3.oclAsType(Integer),
3.oclAsType(Real) }->size() = 1.
Sequence{3, 3.0}->count(3.0) = 1.
Regards
Ed Willink
On 06/01/2010 21:44, Juergen Boldt wrote:
X-IronPort-Anti-Spam-Filtered:
true
X-IronPort-Anti-Spam-Result: ApoEAJklP0tUXebz/2dsb2JhbADRTIQxBA
Date: Sat, 02 Jan 2010 18:56:24 +0000
From: Ed Willink <ed@xxxxxxxxxxxxx>
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@xxxxxxx
Subject: OCL 2.1 11.2.5 Numeric = and <> operations should
compare values
rather than objects
X-Plusnet-Relay: c7b893149f9e819f734970fb3019af3e
Hi
OCLAny::=() is defined as 'True if self is the same object as object2.'
This is not overloaded for numeric types, and it is not specified that
a numeric value may not have multiple instances.
The definition therefore implies that:
1 = 1
may often evaluate to false, and that
1.0 = 1
must evaluate to false even though (1.0 <= 1) and (1.0 >= 1) will
evaluate true
Suggest overload {Boolean, Real, String}::{=,<>} to use values
rather than objects.
Regards
Ed Willink
Juergen Boldt
Director, Member Services
Object Management Group
140 Kendrick St
Building A Suite 300
Needham, MA 02494
USA
tel: +1 781 444 0404 x 132
fax: +1 781 444 0320
email: juergen@xxxxxxx
www.omg.org
_______________________________________________
mdt-ocl.dev mailing list
mdt-ocl.dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/mdt-ocl.dev
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 9.0.730 / Virus Database: 270.14.150/2632 - Release Date: 01/19/10 07:34:00
|