
Key: ALF1129

Legacy Issue Number: 18497

Status: closed

Source: Model Driven Solutions ( Ed Seidewitz)

Summary:
Specification: Action Language for Foundational UML (Alf): Concrete Syntax for a UML Action Language, FTFBeta 2 (ptc/20120843)
Once Alf has been updated to be semantically based fUML 1.1 (see Issue 18393), Alf should also be updated to support the new Real type from UML 2.4.1 that is included in fUML 1.1. This would require both updating the Alf Standard Model Library to provide a RealFunctions package of primitive behaviors and the core Alf syntax and semantics for typing by Real and for operations involving Real values.

Reported: ALF 1.0 — Sat, 23 Feb 2013 05:00 GMT

Disposition: Resolved — ALF 1.1

Disposition Summary:
Add Real support
Adding support for Real expressions and functions to Alf is an involved but extremely important update to the language. The proposal is to update the language as follows:
 Add real literals to the lexical structure of the language. The syntax of these literals should be consistent with the textual syntax given for LiteralReal in UML 2.4.1, subclause 7.3.29/UML 2.5, subclause 8.2.4, with two exceptions:
a) underscores should be support between digits, as in Alf natural literals, and
b) a decimal point should be required if there is no exponent part, to avoid ambiguity between natural literals and real literals. (It is also considered sufficient to only support decimal notation for real literals.)  Add real literal expressions as a new kind of literal expression.
 Import the RealFunctions package from the Foundational Model Library to the Alf Standard Model Library.
 Add a ToReal function to the IntegerFunctions package, to convert an integer value to a real value. (Rationale: The Foundational Model Library does not actually provide an IntegerFunctions::ToReal function. However, it does provide an IntegerFunctions::'/' function that divides two integer values, producing a real value. It is thus possible to convert an integer value to a real value by performing real division by the integer value 1. But the Alf syntax already uses / for truncating integer division of integer values, and introducing another operator for real division of integer values would be difficult. Therefore, it is more straightforward to include a ToReal conversion function, whose functionality is equivalent to dividing by 1 using the fUML IntegerFunctions::'/' function.)
 Add a real conversion condition that allows the assignability of an Integertyped element to a Realtyped element, with the integer value converted to a real value using the IntegerFunctions::ToReal function introduced above. (Rational: The UML primitive type Integer is not a subtype of Real, so integer values and real values are not at all formally related in the UML type system. However, mathematically, integer values are a subset of real values, and a typical user expectation is that "1" represents the same number as "1.0". Automatic real conversion maps integer values to corresponding real values, so that a user can consider the set of integers to be essentially "embedded" in the set of reals. Automatic conversion is not provided in the other direction, from Real to Integer, though, since there are a number of ways to truncate or round real values to integer values, and it is better that the user chooses explicitly how to do this. This is consistent with the situation that would exist if Integer was a subtype of Real – upcasting from Integer to Real would be automatic, but downcasting from Real to Integer would require an explicit cast or conversion.)
 Update the semantics of sequence construction expressions to allow Integertyped elements to be used, with real conversion, in the context of constructing a sequence of real values.
 Update the constraints on increment and decrement expressions and numeric unary expressions to allow operands of type Real.
 Update the constraints on arithmetic and relational expressions to allow operands of type Real. Also allow the case in which one operand is of type Integer and one is of type Real, with automatic real conversion performed on the Integer operand. (Rationale: This is consistent with the introduction of real conversion for assignability.)
 Update the semantics of equality expressions for the case of one operand of type Integer and one of type Real, such that real conversion is performed on the Integer operand before the equality test. (Rationale: The underlying fUML test identity action used to define the semantics of the Alf equality operator always produces false when comparing values of types unrelated by generalization. Since Integer and Real types are not so related, an integer value is never considered equal to a real value by this action. Thus, as equality is currently defined, the Alf expression 1 == 1.0 would evaluate to false, which would probably be unexpected by most users. By introducing automatic real conversion, this expression becomes equivalent to IntegerFunctions::ToReal(1) == 1.0 or 1.0 == 1.0, which is true, as would be expected.)
 Allow real values for tagged values in stereotype annotations.
 Add real literals to the lexical structure of the language. The syntax of these literals should be consistent with the textual syntax given for LiteralReal in UML 2.4.1, subclause 7.3.29/UML 2.5, subclause 8.2.4, with two exceptions:

Updated: Thu, 22 Jun 2017 16:40 GMT
ALF11 — Alf should support Real
 Key: ALF1129
 OMG Task Force: Action Language for fUML 1.1 (ALF) RTF