-
Key: OCL21-197
-
Legacy Issue Number: 6540
-
Status: closed
-
Source: Anonymous
-
Summary:
Author: Thomas Baar (thomas.baar@epfl.ch)
Description: Strict evaluation for queries yields to contradictions in specifications
Rationale: Queries can be specified in two ways, as invariants and in form of pre/post conditions. Suppose we specify query q(arg) as
post: if (arg.oclIsUndefined()) then result = true else result = false endfi
Having this, the following invariant should evaluate always to true:
self.q(arg) = true or self.q(arg) = false.
However, the invariant evaluates to undef once arg evaluates to undef thanks to strict evaluation.
There is a misconception of strict evaluation when it comes to queries. The idea of queries is to have user-defined functions on classes. Why should the user be restricted only to such function which return undef once one of its arguments is undef? Using OCL, the user can even specify queries which can handle undefined arguments (e.g. see post specification of q(arg) ). Obviously, the post specification for q(arg) makes sense.
The rule of strict evaluations for queries should be weakened to the case where the owner of the query (the object upon the query was called) is undefined. -
Reported: OCL 2.0b2 — Mon, 10 Nov 2003 05:00 GMT
-
Disposition: Resolved — OCL 2.1
-
Disposition Summary:
This issue was raised before undefined was clarified as null and invalid. It is now permissible to pass null values to queries. Only invalid values cannot be passed.
Disposition: Closed, no change -
Updated: Fri, 6 Mar 2015 20:58 GMT