-
Key: OCL2_-10
-
Legacy Issue Number: 6546
-
Status: closed
-
Source: Anonymous
-
Summary:
Author: Octavian Patrascoiu (O.Patrascoiu@kent.ac.uk)
{1/0, 1/0}
Description: Most of the modern OO languages support null values, but OCL does not. In order to map null values into OCL concepts we used the undefined value. Unfortunately, OCL offers two choices to test if a value is undefined or not: isEmpty and oclIsUndefined. Using isEmpty for such a purpose is some how confusing:
the result of property->isEmpty() must be true if the value of the property null/undefined
the result of Set->isEmpty() must be false
These situations are a source of errors and confusion at the implementation level. I think that isEmpty() should be used only to test if a collection is empty or not; the undefined values should be tested using ocIslUndefined. This operation should be also valid on collections. This approach will also work nice and clear for nested collections. -
Reported: OCL 2.0b2 — Mon, 10 Nov 2003 05:00 GMT
-
Disposition: Resolved — OCL 2.0
-
Disposition Summary:
The submitter’s assertion about appropriate usage of oclIsUndefined() and isEmpty() is a matter of style. OCL does support null values, even in collections, so that a collection containing a single element that is null is not empty. The isEmpty() operation applied to scalar values that are null is an inevitable consequence of the coercion of scalars to sets. It is reasonable that a scalar null is coerced to an empty set while a non-null scalar is coerced to a non-empty set. Moreover, oclIsUndefined() is true not only for null, but also for invalid, which is not permitted in collections.
Disposition: Closed, no change
-
Updated: Sun, 8 Mar 2015 13:35 GMT