7.4 Use of Infix Operators


7.4 Use of Infix Operators

The use of infix operators is allowed in OCL. The operators +, -, *, /, <, >, <>, <=, and >= are used as infix operators. If a user -defined type includes one of those operators with the correct signature, it will also be used as an infix operator. The correct signature includes only one parameter of the same type as the contextual instance. For the infix operators <, >, <=, >=, <>, and, or , and xor , the return type must be Boolean . For the infix operators +, -, *, and /, the return type must be equal to the type of the contextual instance.

Conceptually, the following two expressions are completely equal; both invoke the + operation on a , with b as the parameter to the operation. The second notation is not allowed:

 a + b a.+(b) 


Object Constraint Language, The. Getting Your Models Ready for MDA
The Object Constraint Language: Getting Your Models Ready for MDA (2nd Edition)
ISBN: 0321179366
EAN: 2147483647
Year: 2003
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net