CVS difference for ai12s/ai12-0226-1.txt

Differences between 1.1 and version 1.2
Log of other versions for file ai12s/ai12-0226-1.txt

--- ai12s/ai12-0226-1.txt	2017/04/19 04:06:10	1.1
+++ ai12s/ai12-0226-1.txt	2018/04/10 02:42:56	1.2
@@ -1,57 +1,33 @@
-!standard 3.3(11.1/3)                                  17-04-18  AI12-0226-1/01
-!standard 3.3(12)
-!standard 3.3(21/3)
-!standard 3.3(22)
+!standard 3.3(11.1/3)                                  18-04-09  AI12-0226-1/02
+!standard 3.3(21.1/3)
 !standard 3.3(23.7/3)
-!standard 3.10(9/3)
 !standard 4.6(58.1/4)
-!standard 4.6(58.4/4)
+!standard 4.6(58.3/4)
 !class Amendment 17-04-18
 !status work item 17-04-18
 !status received 17-03-23
 !priority Low
 !difficulty Easy
-!subject Generalize expressions that are objects
+!subject Make objects more consistent
 !summary
 
-Value conversions represent objects in the same way as a function call
-represents an object. A parenthesized expression of an object represents
-an object.
+Value conversions of an object is an object in order to be consistent with 
+qualified expressions.
 
 !problem
 
-After various changes in Ada 95 and Ada 2012, there is no rhyme nor reason
-to the difference between expressions that represent objects and those
-that represent values. Consider the following:
+Ada 2012 made qualified expressions "name"s, and qualified expressions of
+an object is an object. This created an unusual situation where a single
+character makes a difference between constructs usually considered equivalent:
 
-    Limit : constant := 10;
     Max   : constant Natural := 10;
 
-    Ren1 : Natural renames Natural'(1);  -- Illegal, not object.
-    Ren2 : Natural renames Natural'(+1); -- Legal, "+1" is equivalent to a
-                                         -- function call "+"(1), and the result
-                                         -- result object of a function call
-                                         -- is clearly an object [3.3(13)].
-    Ren3 : Natural renames Natural(+1);  -- Illegal, not object (value
-                                         -- conversion isn't an object).
-    Ren4 : Natural renames Natural'First;-- Illegal, not object.
-    Ren5 : Natural renames Natural'Val(1); -- Legal, object. (Val denotes a
-                                         -- function.)
-    Ren6 : Natural renames Natural'(Max);-- Legal, object.
-    Ren7 : Natural renames Natural'(Limit); -- Illegal, not object. (A named
-                                         --    number is not an object.)
-    Ren8 : Natural renames Max;          -- Legal, object.
-    Ren9 : Natural renames (Max);        -- Illegal, not object. (A parenthesized
-                                         -- expression is not an object,
-                                         -- regardless of what is
-                                         -- parenthesized.)
-    RenA : Boolean renames Boolean'(A and B); -- Legal, object. ("and" is
-                                              -- a function.)
-    RenB : Boolean renames Boolean'(A and then B); -- Illegal, not object
-                                  -- ("and then" is an operation, not a function.)
+    Ren1 : Natural renames Max;          -- Legal.
+    Ren2 : Natural renames Natural'(Max);-- Legal, object.
+    Ren3 : Natural renames Natural(Max); -- Illegal, not object. (A value
+                                         --    conversion is not an object.)
 
-How many of you got this right? We should at least fix the worst warts of this
-list.
+This inconsistency in the language is easily repaired.
 
 !proposal
 
@@ -61,68 +37,44 @@
 
 [The definition of object:]
 
-Add after 3.3(11.1/3):
+Modify 3.3(11.1/3):
 
-* a value conversion;
+* a {value conversion} or qualified_expression whose operand denotes an object;
 
-Modify 3.3(12):
-
-* a component, slice, {parenthesized expression}, or view conversion
-  of another object.
-
-[Note: "expression" of parenthesized expression is in the syntax font.]
-
 [The definition of constants:]
-
-Modify 3.3(21/3):
 
-*  the object denoted by a {value conversion, }function_call{,} or
-   [an] aggregate;
+Modify 3.3(21.1/3):
 
-Modify 3.3(22/3):
+*  the result of evaluating a {value conversion or }qualified_expression;
 
-* a selected_component, indexed_component, slice, {parenthesized expression},
-  or view conversion of a constant.
-
 [The definition of known to be constrained:]
 
 Modify 3.3(23.7/3):
 
 * it is part of the object denoted by a {value conversion, }function_call{,}
   or aggregate; or
-{* it is a parenthesized expression where the expression denotes a view of a
-   composite object that is known to be constrained;}
-
-Modify 3.10(9/3):
 
-A view of an object is defined to be aliased if it is defined by an
-object_declaration, component_definition, parameter_specification, or
-extended_return_object_declaration with the reserved word aliased, or by a
-renaming of an aliased view. In addition, the dereference of an
-access-to-object value denotes an aliased view, as does a view conversion (see
-4.6) of an aliased view. {A parenthesized expression where the expression
-denotes an aliased view is an aliased view.} The current instance of an
-immutably limited type (see 7.5) is defined to be aliased. Finally, a formal
-parameter or generic formal object of a tagged type is defined to be aliased.
-[Aliased views are the ones that can be designated by an access value.]
-
 Modify 4.6(58.1/4):
 
-Evaluation of a value conversion [of a composite type] either creates a new
-anonymous object Redundant[(similar to the object created by the evaluation
-of an aggregate or a function call)] or yields a new view of the operand
-object without creating a new object:
+Evaluation of a value conversion [of a composite type] either creates a 
+{new value, a }new anonymous object Redundant[(similar to the object
+created by the evaluation of an aggregate or a function call)]{,} or
+yields a new view of the operand object without creating a new object:
 
-Add after 4.6(58.4/4):
+Add after 4.6(58.3/4):
 
-If the target type is an elementary type, then a new object is created;
+If the target type is an elementary type and the operand is an object, then
+a new object is created;
 
 Add after AARM 4.6(58.b.1/4):
 
 AARM Implementation Note: The new temporary object need not be materialized
 in most cases; it should be handled like the return object of a predefined
 operator. Generally, whether the object exists can only be detected if it
-is renamed (as an elementary type cannot be controlled).
+is renamed (unless the type is controlled).
+
+AARM Discussion: We allow creating a value in those cases where the ultimate
+result is not an object (such as a value conversion of a named number).
 
 !discussion
 
@@ -134,29 +86,39 @@
 only when it is required, as is typically done for the result object of
 predefined operators.
 
-We also make the result of a parenthesized object an object, so that
-parenthesized expressions and qualified expressions have the same static
-semantics.
-
-The other kinds of expressions that are not objects are:
-
- * numeric literals;
- * the literal null;
- * named numbers;
- * membership tests;
- * short circuit control forms;
- * attributes that are not defined as functions.
-
-We considered defining everything to be an object, but it seemed strange that
-a literal like 12 or null would be an object. Named numbers are intended to
-work like literals. There doesn't seem to be much use to renaming boolean
-expression, so we didn't change either of those, either. And changing a number
-of attribute definitions seemed like dimishing returns.
+We made value conversions consistent with qualified expressions in the wording
+above, but we could have made them consistent with function calls instead.
+The wording differences are minimal (drop "new value," and the associated
+AARM discussion from 4.6(58.1/4), and put "value conversion" with function
+call rather than qualified expression in 3.3 [two places]). The difference can
+be seen when renaming uses of named numbers:
+
+     Limit : constant := 12;
+     function Func (A : Natural) return Natural ...
+
+     RenA : Natural renames Natural'(Limit); -- Illegal, not object.
+     RenB : Natural renames Natural(Limit);  -- (A)
+     RenC : Natural renames Func(Limit);     -- OK, object by Ada 95.
+
+(A) is illegal with the wording as suggested, and would be legal with the more
+general wording mentioned here. With either wording in this AI, all three
+would be legal if Limit had been a constant object (if a subtype had been
+given in the declaration).
+
+We also considered making the result of a parenthesized object an object,
+so that parenthesized expressions and qualified expressions have the same
+static semantics. However, since a parenthesized object should be considered
+a constant and is not syntactically a name, there does not appear to be any
+places where such a construct could be used.
+
+A more general fix would be to eliminate the distinctions between "name" and
+"expression" as well as "object" and "value", but that would require extensive
+surgery to the Standard, so it is is not simple and is covered in a separate
+AI - AI12-0270-1.
 
 !ASIS
 
-[Not sure. It seems like some new capabilities might be needed for operators,
-but I didn't check - Editor.]
+[Probably not, but not certain - Editor.]
 
 !ACATS test
 

Questions? Ask the ACAA Technical Agent