CVS difference for ai05s/ai05-0096-1.txt
--- ai05s/ai05-0096-1.txt 2008/05/29 01:41:25 1.2
+++ ai05s/ai05-0096-1.txt 2008/07/12 01:18:27 1.3
@@ -1,6 +1,7 @@
-!standard 3.4(5.1/2) 08-05-28 AI05-0096-1/02
+!standard 3.4(5.1/2) 08-07-11 AI05-0096-1/03
!standard 6.2(7)
!class binding interpretation 08-05-23
+!status ARG Approved 7-0-1 08-06-22
!status work item 08-05-23
!status received 06-05-21
!priority Medium
@@ -31,21 +32,21 @@
The template is legal, but the instance seems to violate 3.4(5.1/2). However,
that rule is not rechecked in the instance (it doesn't have the boilerplate
-wording for that), so this is legal. Is that intended?
+wording for that), so this is legal. Is that intended? (Yes if untagged.)
!wording
Add to 3.4(5.1/2):
-If the parent type is a tagged formal type, in addition to the places where
-Legality Rules normally apply (see 12.3), this rule applies also in the
-private part of an instance of a generic unit.
+If the parent type is a tagged formal type, then in addition to the places
+where Legality Rules normally apply (see 12.3), this rule applies also in
+the private part of an instance of a generic unit.
-AARM Note: If the parent type is a untagged limited formal type with an
+AARM Note: If the parent type is an untagged limited formal type with an
actual type that is nonlimited, we allow derivation as a limited type in
the private part or body as no place could have visibility on the resulting
type where it was known to be nonlimited (outside of the instance).
-(See the previous paragraph's AARM notes for an explanation of this.) However,
+(See the previous paragraph's annotations for an explanation of this.) However,
if the parent type is a tagged limited formal type with an actual type that is
nonlimited, it would be possible to pass a value of the limited type extension
to a classwide type of the parent, which would be nonlimited. That's too weird
@@ -58,7 +59,9 @@
* an explicitly limited record type;
-Move the Ramification 6.2(7.a) after the bulleted list.
+Delete the Ramification 6.2(7.a); it makes no sense here (there is no longer
+any mention of private here) and it essentially repeats the rule (just adding
+limited) if moved after 6.2(9).
!discussion
@@ -89,6 +92,38 @@
corresponding to the parent type. If that parent type is also nonlimited,
we could then assign a limited tagged type.
+An example should make this clearer:
+
+ generic
+ type Lim is tagged limited private;
+ with procedure Do_It (Obj : in Lim'Class);
+ package Gen is
+ ...
+ private
+ type New_Lim is limited new Lim with null record;
+ end Gen;
+
+
+ type Non_Lim_Tagged is tagged record ...;
+ Global : access Non_Lim_Tagged'Class;
+
+ procedure Copy_It (Obj : in Non_Lim_Tagged'Class) is
+ begin
+ Global := new Non_Lim_Tagged'Class'(Obj);
+ end Copy_It;
+
+ package New_Gen is new Gen (Non_Lim_Tagged, Copy_It); -- Error:
+
+
+Here, the template is clearly legal (the parent type is limited). However,
+the body of the generic could call Do_It with an object of type New_Lim.
+Moreover, the actual subprogram for that formal could copy the object, as
+in this example. That would be a weird thing to do with a type that was
+explicitly declared to be limited. Therefore, we recheck this rule in the
+private part for tagged types (a type extension from a formal type is
+illegal in a generic body anyway, so it doesn't pose a problem).
+
+
An objection was raised to this intepretation noting that a limited derived
type is covered by 6.2(7), and thus such a type would be a by-reference type.
That appears to be a problem if the actual type is by-copy; it surely cannot
@@ -110,7 +145,7 @@
with P;
package Q is
- type New_LP is new P.LP;
+ type New_LP is limited new P.LP;
end Q;
6.2(7) says that New_LP is a by-reference type; thus a call on the inherited
@@ -126,8 +161,26 @@
derived types (the incorrect case that we want to exclude from 6.2(7)), limited
with clauses (irrelevant here), limited interfaces (covered by 6.2(5), so they
don't need to be covered by 6.2(7)), and explicitly limited record types.
+
+!corrigendum 3.4(5.1/2)
+
+@drepl
+If the reserved word @b<limited> appears in a @fa<derived_type_definition>,
+the parent type shall be a limited type.
+@dby
+If the reserved word @b<limited> appears in a @fa<derived_type_definition>,
+the parent type shall be a limited type.
+If the parent type is a tagged formal type, then in addition to the places
+where Legality Rules normally apply (see 12.3), this rule applies also in
+the private part of an instance of a generic unit.
+
+!corrigendum 6.2(7)
+
+@drepl
+@xbullet<[a nonprivate type with the reserved word @key[limited] in its declaration;>
+@dby
+@xbullet<an explicitly limited record type;>
---!corrigendum 3.4(5.1/2)
!ACATS Test
Questions? Ask the ACAA Technical Agent