CVS difference for ai05s/ai05-0162-1.txt
--- ai05s/ai05-0162-1.txt 2010/01/30 05:28:01 1.2
+++ ai05s/ai05-0162-1.txt 2010/04/03 02:08:32 1.3
@@ -1,8 +1,10 @@
-!standard 3.10.1(2.5/2) 10-01-29 AI05-0162-1/02
+!standard 3.10.1(2.5/2) 10-04-02 AI05-0162-1/03
!standard 3.10.1(2.6/2)
!standard 3.10.1(3)
!standard 3.10.1(4/2)
!class Amendment 09-10-15
+!status Amendment 2012 10-04-02
+!status ARG Approved 10-0-0 10-02-26
!status work item 09-10-15
!status received 09-10-15
!priority Medium
@@ -16,64 +18,18 @@
!problem
-If an interface is parameterized by a type, it is not unusual that it be defined as a generic
-unit. If that interface is needed in another generic, a fairly complex organization is
-needed.
-
-For instance, the proposed iterator generic looks like:
-
- generic
- type Cursor is private;
- No_Element : in Cursor;
- package Ada.Iterator_Interfaces is
- type Basic_Iterator is limited interface;
- function First (Object : Basic_Iterator) return Cursor is abstract;
- function Next (Object : Basic_Iterator; Position : Cursor)
- return Cursor is abstract;
- end Ada.Iterator_Interfaces;
-
-One way to use this in the existing containers packages would be:
-
- with Ada.Iterator_Interfaces;
- generic
- type Element_Type is private;
- package Ada.Containers.Doubly_Linked_Lists is
- type List is tagged;
- package Cursors is
- type Cursor is private;
- No_Element : constant Cursor;
- private
- -- not specified by the language, but here is a likely implementation.
- type Node is ... -- Not relevant.
- type Cursor is record
- My_Container : access List;
- My_Node : access Node;
- end record;
- end Cursors;
- subtype Cursor is Cursors.Cursor;
- No_Element : Cursor renames Cursors.No_Element;
-
- package Iterators is new
- Ada.Iterator_Interfaces (Cursor, No_Element);
-
- type List is new Iterators.Basic_Iterator with private; -- (1)
-
- Empty_List : constant List;
- function Is_Empty (Container : List) return Boolean;
- procedure Clear (Container : in out List);
- function Element (Position : Cursor)
- return Element_Type;
- ...
- private
- -- not specified by the language
- end Ada.Containers.Doubly_Linked_Lists;
-
-Since a cursor needs to have an access to a List container, we need to declare it
-incomplete at the very start of the package. But the completion is a private
-extension, and that is not allowed by 3.10.1(3).
+The use of an incomplete type prevents the use of information hiding for that
+type, as 3.10.1(3) does not allow completing an incomplete type with a private
+type.
+
+For instance, consider the declaration of two types which each have the other
+as an access discriminant. One of the two types cannot be private:
+
+ type T1;
+ type T2 (X : access T1) is private;
+ type T1 (X : access T2) is private; -- Illegal by 3.10.1(3).
-Eliminating this limitation would allow this package structure (and without
-requiring any new features).
+This limitation should be removed.
!proposal
@@ -96,7 +52,7 @@
Modify 3.10.1(3):
An incomplete_type_declaration requires a completion, which shall be a {type_declaration
-other than an incomplete_type_declaration[full_type_declaration]. If the
+other than an incomplete_type_declaration}[full_type_declaration]. If the
incomplete_type_declaration occurs immediately within either the visible part of a
package_specification or a declarative_part, then the {type_declaration}[full_type_declaration]
shall occur later and immediately within this visible part or declarative_part. If the
@@ -125,7 +81,7 @@
An incomplete type (whether declared in the limited view of a
package or not) may be completed by a private type declaration,
- so we can have four parts now.
+ so we can in fact have four parts.
[Author's note: The proper body corresponding to a body_stub is not considered to be a
"completion", so four parts is the right number even if a task body has a stub.]
@@ -138,7 +94,8 @@
The various AIs suggesting features to allow partial instances, not-private parts, and
integrated packages don't help in this situation. But some way to do this will be needed
-if AI05-0139-1 or an alternative is adopted using the magic generic interface idea.
+if AI05-0139-1 or an alternative is adopted using the magic generic interface idea (see
+the !example below).
3.10.1(1) talks about deferring the declaration to a subsequent full type declaration;
@@ -146,12 +103,130 @@
!example
-(See problem.)
+If an interface is parameterized by a type, it is not unusual that it be defined as a generic
+unit. If that interface is needed in another generic, a fairly complex organization is
+needed.
+
+For instance, the proposed iterator generic looks like:
+
+ generic
+ type Cursor is private;
+ No_Element : in Cursor;
+ package Ada.Iterator_Interfaces is
+ type Basic_Iterator is limited interface;
+ function First (Object : Basic_Iterator) return Cursor is abstract;
+ function Next (Object : Basic_Iterator; Position : Cursor)
+ return Cursor is abstract;
+ end Ada.Iterator_Interfaces;
+
+One way to use this in the existing containers packages would be:
+
+ with Ada.Iterator_Interfaces;
+ generic
+ type Element_Type is private;
+ package Ada.Containers.Doubly_Linked_Lists is
+ type List is tagged;
+ package Cursors is
+ type Cursor is private;
+ No_Element : constant Cursor;
+ private
+ -- not specified by the language, but here is a likely implementation.
+ type Node is ... -- Not relevant.
+ type Cursor is record
+ My_Container : access List;
+ My_Node : access Node;
+ end record;
+ end Cursors;
+ subtype Cursor is Cursors.Cursor;
+ No_Element : Cursor renames Cursors.No_Element;
+
+ package Iterators is new
+ Ada.Iterator_Interfaces (Cursor, No_Element);
+
+ type List is new Iterators.Basic_Iterator with private; -- (1)
+
+ Empty_List : constant List;
+ function Is_Empty (Container : List) return Boolean;
+ procedure Clear (Container : in out List);
+ function Element (Position : Cursor)
+ return Element_Type;
+ ...
+ private
+ -- not specified by the language
+ end Ada.Containers.Doubly_Linked_Lists;
+
+Since a cursor needs to have an access to a List container, we need to declare it
+incomplete at the very start of the package. Without the change proposed by this
+AI, this structure would be illegal as the completion is a private extension.
---!corrigendum 3.10.1(3)
---!corrigendum 3.10.1(4/2)
+!corrigendum 3.10.1(2.5/2)
+@drepl
+In these cases, the dereference has the full view of T.
+@dby
+In these cases, the dereference has the view of T visible at the point of the
+dereference.
+
+!corrigendum 3.10.1(2.6/2)
+
+@drepl
+Similarly, if a @fa<subtype_mark> denotes a @fa<subtype_declaration> defining a
+subtype of an incomplete view @i<T>, the @fa<subtype_mark> denotes an incomplete
+view except under the same two circumstances given above, in which case it denotes
+the full view of @i<T>.
+@dby
+Similarly, if a @fa<subtype_mark> denotes a @fa<subtype_declaration> defining a
+subtype of an incomplete view @i<T>, the @fa<subtype_mark> denotes an incomplete
+view except under the same two circumstances given above, in which case it denotes
+the view of @i<T> visible at the point of the @fa<subtype_mark>.
+
+!corrigendum 3.10.1(3)
+
+@drepl
+An @fa<incomplete_type_declaration> requires a completion, which shall
+be a @fa<full_type_declaration>. If the @fa<incomplete_type_declaration> occurs
+immediately within either the visible part of a @fa<package_specification> or a
+@fa<declarative_part>, then the @fa<full_type_declaration> shall occur later and
+immediately within this visible part or @fa<declarative_part>.
+If the @fa<incomplete_type_declaration> occurs immediately within the private part
+of a given @fa<package_specification>, then the @fa<full_type_declaration> shall occur
+later and immediately within either the private part itself, or the @fa<declarative_part>
+of the corresponding @fa<package_body>.
+@dby
+An @fa<incomplete_type_declaration> requires a completion, which shall
+be a @fa<type_declaration> other than an @fa<incomplete_type_declaration}. If the
+@fa<incomplete_type_declaration> occurs
+immediately within either the visible part of a @fa<package_specification> or a
+@fa<declarative_part>, then the @fa<type_declaration> shall occur later and
+immediately within this visible part or @fa<declarative_part>.
+If the @fa<incomplete_type_declaration> occurs immediately within the private part
+of a given @fa<package_specification>, then the @fa<type_declaration> shall occur
+later and immediately within either the private part itself, or the @fa<declarative_part>
+of the corresponding @fa<package_body>.
+
+!corrigendum 3.10.1(4/2)
+
+@drepl
+If an @fa<incomplete_type_declaration> includes the reserved word @b<tagged>, then a
+@fa<full_type_declaration> that completes it shall declare a tagged type.
+If an @fa<incomplete_type_declaration> has a @fa<known_discriminant_part>, then
+a @fa<full_type_declaration> that completes it shall have a fully conforming
+(explicit) @fa<known_discriminant_part> (see 6.3.1). If an
+@fa<incomplete_type_declaration> has no @fa<discriminant_part> (or an
+@fa<unknown_discriminant_part>), then a corresponding @fa<full_type_declaration>
+is nevertheless allowed to have discriminants, either explicitly, or inherited
+via derivation.
+@dby
+If an @fa<incomplete_type_declaration> includes the reserved word @b<tagged>, then a
+@fa<type_declaration> that completes it shall declare a tagged type.
+If an @fa<incomplete_type_declaration> has a @fa<known_discriminant_part>, then
+a @fa<type_declaration> that completes it shall have a fully conforming
+(explicit) @fa<known_discriminant_part> (see 6.3.1). If an
+@fa<incomplete_type_declaration> has no @fa<discriminant_part> (or an
+@fa<unknown_discriminant_part>), then a corresponding @fa<type_declaration>
+is nevertheless allowed to have discriminants, either explicitly, or inherited
+via derivation.
!ACATS test
Questions? Ask the ACAA Technical Agent