CVS difference for ais/ai-00313.txt

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

--- ais/ai-00313.txt	2003/05/24 00:51:42	1.4
+++ ais/ai-00313.txt	2003/11/27 02:01:15	1.5
@@ -93,3 +93,77 @@
 would be relatively easy.
 
 ****************************************************************
+
+From: Adam Beneschan
+Sent: Wednesday, November  5, 2003  11:41 AM
+
+Back in September 2002, we had discussed the possibility of allowing
+the declaration of an access-to-subprogram type T to refer to T in the
+subprogram parameters or return type:
+
+[Adam Beneschan:]
+>
+> Is there any reason why this should be illegal?
+>
+>    type Chaining_Procedure is access procedure
+>             (...<other parameters>...; Next_Proc :
+>             Chaining_Procedure);
+>
+> This is illegal by 8.3(16) [and declaring Chaining_Procedure as an
+> incomplete type prior to this doesn't help, because of 8.3(19)].
+> However, someone may want to do something like this, and there aren't
+> any implementation problems that I can think of.
+>
+> (The best workaround I can think of is to add a new type:
+>
+>    type Chaining_Procedure_2;
+>    type Chaining_Procedure is access procedure
+>             (...<other parameters>...; Next_Proc :
+>    Chaining_Procedure_2);
+>    type Chaining_Procedure_2 is new Chaining_Procedure;
+>
+> which may necessitate a type conversion in some cases.)
+>
+> Anyway, this may not be a high priority, but it seems harmless to me
+> to add another exception after 8.3(17) that for an
+> access-to-subprogram type declaration, the declaration is hidden from
+> all visibility only until the reserved word "access".
+
+[Randy Brukardt:]
+>
+> I do agree its harmless, but even so, its additional work. (Figuring
+> out how to change 'hidden from all visibility' is non-trivial in
+> Janus/Ada, at least). Given that, I'd like to know if anyone has run
+> into this problem in practice. If not, perhaps it is not worth the
+> effort to change even if it would be relatively easy.
+
+It appears that someone has now run into this problem; see the thread
+"Problem with Self-Referential Access-To-Subprogram Type" on
+comp.lang.ada.  Here's the source the poster (a self-described "Ada
+newbie") was trying to use:
+
+    package Test is
+       --  A little ADT:
+       type Test_Type is tagged private;
+       function Get_Dummy (Tester : Test_Type) return Integer;
+       procedure Set_Dummy (Tester : in out Test_Type; Dummy : in Integer);
+
+       --  An access-to-function type that works (but Tester is read-only):
+       type State1;
+       type State1 is access function (Tester : Test_Type'Class)
+                                      return State1;
+       --  An access-to-procedure type that doesn't work:
+       type State2;
+       type State2 is access procedure (Tester : in out Test_Type'Class;
+                                        Resultant_State : out State2);
+       --                premature use of "State2" right here ^
+    private
+       type Test_Type is
+         tagged record
+            Dummy : Integer;
+         end record;
+    end Test;
+
+(The declaration of State1 should not have compiled.)
+
+****************************************************************

Questions? Ask the ACAA Technical Agent