CVS difference for ais/ai-00231.txt

Differences between 1.5 and version 1.6
Log of other versions for file ais/ai-00231.txt

--- ais/ai-00231.txt	2003/06/07 04:58:55	1.5
+++ ais/ai-00231.txt	2003/06/27 23:46:27	1.6
@@ -1,4 +1,4 @@
-!standard  3.10      (06)                        01-10-01  AI95-00231/02
+!standard  3.10      (06)                        03-06-21  AI95-00231/03
 !standard  3.10      (12)
 !standard  4.6       (49)
 !standard  8.6       (25)
@@ -12,9 +12,10 @@
 !summary
 
 Parameters and discriminants of an anonymous access-to-constant type are
-introduced. Access parameters and access discriminants are generalized
-to have a variant that allows a null value. Null-excluding subtypes of
-a named access type are introduced.
+introduced. Non-controlling access parameters and access discriminants
+are changed to allow having a null value by default, but allow null to
+be excluded explicitly. Null-excluding subtypes of a named access type
+are introduced.
 
 !problem
 
@@ -22,8 +23,17 @@
 
 !proposal
 
-Introduce a not-null constraint, and an access_constraint syntactic category.
+Change non-controlling access parameters and access discriminants to
+allow them to have null values.
 
+Introduce a not-null constraint, and an access_constraint syntactic
+category.
+
+Generalize access_definition to allow specification of
+access-to-constant, and a not-null constraint.
+
+!wording
+
 Modify 3.2.2(5) to:
     constraint ::= scalar_constraint | access_constraint | composite_constraint
 
@@ -35,22 +45,20 @@
     not_null_constraint ::= NOT NULL
 
     access_definition ::=
-       ACCESS ALL subtype_mark [not_null_constraint]
-     | ACCESS CONSTANT subtype_mark [not_null_constraint]
-     | ACCESS subtype_mark
+       ACCESS [CONSTANT] subtype_mark [not_null_constraint]
 
 Modify 3.10(12) to:
 
     An access_definition defines an anonymous general access type; the subtype
-    mark denotes its @i<designated subtype>. If the word @b<all> appears, the
-    type is an access-to-variable type. If the word @b<constant> appears, the
-    type is an access-to-constant type. If the words @b<not null> appear, the
-    access_definition defines an access subtype which excludes the null
-    value. If neither @b<all> nor @b<constant> appear, the access definition is
-    equivalent to having both @b<all> and @b<not null> present, and hence
-    defines an access-to-variable subtype that excludes the null value. An
-    access_definition is used in the specification of an access discriminant
-    (see 3.7) or an access parameter (see 6.1).
+    mark denotes its @i<designated subtype>. If the word @b<constant> appears,
+    the type is an access-to-constant type; otherwise it is an
+    access-to-variable type. If a not_null_constraint is present, or the
+    access_definition is for a controlling access parameter (see 3.9.2), the
+    access_definition defines an access subtype which excludes the null value;
+    otherwise the subtype includes a null value. An access_definition is used
+    in the specification of an access discriminant (see 3.7) or an access
+    parameter (see 6.1). [NOTE: Drop this last sentence or make it cover all
+    uses of access_definition if AI-230 is approved.]
 
 Drop the parenthetical "(named)" from the first sentence of 3.10(13), since in
 our new model, anonymous access types have a null value, even though a subtype
@@ -80,12 +88,20 @@
 permitted, with the expected rules (i.e. it is illegal to convert an
 access-to-constant to access-to-variable).
 
-!wording
+!example
 
-(See proposal.)
+    type Non_Null_Ptr is access T not null;
 
-!example
+    procedure Show(X : Non_Null_Ptr);
+      -- X guaranteed to not be null
 
+    procedure Pass_By_Ref(Y : access constant Rec not null);
+      -- Pass Y by reference, but don't allow it to be updated;
+      -- Guarantee Y is non-null.
+
+    procedure Display(W : access Window; G : access constant Graph'Class);
+      -- Allow any pointer to a graph to be passed to the window
+      -- display routine; allow null to be passed as well.
 
 !discussion
 
@@ -103,9 +119,18 @@
 The rule disallowing "null" for access parameters and access discriminants has
 turned out to be confusing, and not what is wanted in all cases when
 interfacing with a foreign language. Therefore, we propose to define an
-explicit way to exclude nulls from an access subtype, make "access all T" and
-"access constant T" includes nulls by default, but for backward compatibility
-make "access T" a shorthand for "access all T not null."
+explicit way to exclude nulls from an access subtype, and make "access T" and
+"access constant T" include nulls by default when not a controlling parameter,
+even though this does not preserve complete upward compatibility. Note that
+the only incompatibility is for cases where null was passed, and these would
+have been rejected at compile-time or have raised Constraint_Error. It was
+felt it was better to have this upward incompatibility than to have the default
+be null-excluding for "access T" but not null-excluding for "access constant
+T". Note that there is no upward incompatibility for controlling access
+parameters; they always have null-excluding subtypes. Any worrisome loss of
+efficiency due to allowing null for non-controlling access parameters, or
+access discriminants, can be reversed by using an explicity
+not_null_constraint.
 
 The general ability to specify an access subtype that excludes null for both
 named and anonymous access types can provide useful documentation and higher

Questions? Ask the ACAA Technical Agent