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

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

--- ai12s/ai12-0347-1.txt	2019/10/29 06:25:34	1.2
+++ ai12s/ai12-0347-1.txt	2020/01/30 01:56:16	1.3
@@ -1,5 +1,7 @@
-!standard 12.6(15)                                    19-10-28  AI12-0347-1/01
+!standard 12.6(15)                                    20-01-29  AI12-0347-1/02
+!standard E.4.2(5)
 !class presentation 19-10-28
+!status Amendment 1-2012 20-01-29
 !status work item 19-10-28
 !status received 19-10-28
 !priority Low
@@ -8,13 +10,21 @@
 !subject Presentation issues
 !summary
 
+[Editor's note: These changes are included in the current draft of the 
+Standard, even though they are not yet approved.]
+
 (1) Replace the fragment "_instantiation" with "generic_instantation".
 
+(2) Add a specification for Rewind.
+
 !question
 
 (1) There seems to be a typo in 12.6(15): "...directly visible at the place 
 of the _instantiation."
 
+(2) The example in E.4.2 is illegal; the occurrence of the Copy body freezes 
+type New_Tape and thus the later overriding declaration of Rewind is illegal.
+
 !response
 
 (1) This is not a typo; "_instantiation" is in the syntax font. This appears
@@ -22,9 +32,12 @@
 longer to justify the shorthand (and the confusion and queries like this one
 that it causes), so we replace the shorthand by the full term.
 
+(2) This is correct, a separate specification is required for Rewind. We add
+overriding indicators as well to clarify what is going on.
+
 !wording
 
-Modify 12.6(15):
+(1) Modify 12.6(15):
 
 A default_name denotes an entity that is visible or directly visible at the 
 place of the generic_declaration; a box used as a default is equivalent to a
@@ -34,6 +47,35 @@
 [Editor's note: There are three similar occurrences in AARM notes in Clause 12;
 we also change those.]
 
+(2) Modify E.4.2(5):
+
+with Tapes, Name_Server;
+package body Tape_Driver is
+   type New_Tape is new Tapes.Tape with ...
+   {overrriding
+   procedure Rewind (T : access New_Tape);
+   overriding}
+   procedure Copy
+    (From, To : access New_Tape; Num_Recs: in Natural) is
+   begin
+     . . .
+   end Copy;
+   procedure Rewind (T : access New_Tape) is
+   begin
+      . . .
+   end Rewind;
+   -- Objects remotely accessible through use
+   -- of Name_Server operations
+   Tape1, Tape2 : aliased New_Tape;
+begin
+   Name_Server.Register ("NINE-TRACK",  Tape1'Access);
+   Name_Server.Register ("SEVEN-TRACK", Tape2'Access);
+end Tape_Driver;
+
+[Editor's note: this is the minimum change. A real program probably would give
+all of the overriding specifications. But a real program probably wouldn't have
+a type extension in a body, either.]
+
 !corrigendum 12.6(15)
 
 @drepl
@@ -42,12 +84,58 @@
 equivalent to a name that denotes an entity that is directly visible at the place 
 of the @fa<_instantiation>.>>
 @dby
-@xindent<@s9<NOTES@hr
 @xindent<@s9<17  A @fa<default_name> denotes an entity that is visible or directly
 visible at the place of the @fa<generic_declaration>; a box used as a default is 
 equivalent to a name that denotes an entity that is directly visible at the place 
 of the @fa<generic_instantiation>.>>
 
+!corrigendum E.4.2(5)
+
+@drepl
+@xcode<@b<with> Tapes, Name_Server;
+@b<package body> Tape_Driver @b<is>
+   @b<type> New_Tape @b<is new> Tapes.Tape @b<with> ...
+   @b<procedure> Copy
+    (From, To : @b<access> New_Tape; Num_Recs: @i<in> Natural) @b<is>
+   @b<begin>
+     . . .
+   @b<end> Copy;
+   @b<procedure> Rewind (T : @b<access> New_Tape) @b<is>
+   @b<begin>
+      . . .
+   @b<end> Rewind;
+   @ft<@i<-- Objects remotely accessible through use>>
+   @ft<@i<-- of Name_Server operations>>
+   Tape1, Tape2 : @b<aliased> New_Tape;
+@b<begin>
+   Name_Server.Register ("NINE-TRACK",  Tape1'Access);
+   Name_Server.Register ("SEVEN-TRACK", Tape2'Access);
+@b<end> Tape_Driver;>
+@dby
+@xcode<@b<with> Tapes, Name_Server;
+@b<package body> Tape_Driver @b<is>
+   @b<type> New_Tape @b<is new> Tapes.Tape @b<with> ...
+   @b<overriding>
+   @b<procedure> Rewind (T : @b<access> New_Tape);
+   @b<overriding>
+   @b<procedure> Copy
+    (From, To : @b<access> New_Tape; Num_Recs: @i<in> Natural) @b<is>
+   @b<begin>
+     . . .
+   @b<end> Copy;
+   @b<procedure> Rewind (T : @b<access> New_Tape) @b<is>
+   @b<begin>
+      . . .
+   @b<end> Rewind;
+   @ft<@i<-- Objects remotely accessible through use>>
+   @ft<@i<-- of Name_Server operations>>
+   Tape1, Tape2 : @b<aliased> New_Tape;
+@b<begin>
+   Name_Server.Register ("NINE-TRACK",  Tape1'Access);
+   Name_Server.Register ("SEVEN-TRACK", Tape2'Access);
+@b<end> Tape_Driver;>
+
+
 !ASIS
 
 No ASIS effect.
@@ -120,5 +208,69 @@
 true, even version 1.2 of Ada 9x uses "generic_instantiation". It's not at 
 all obvious what the reason for this text was, 7 characters hardly seems
 worth omitting when that necessarily makes things less clear.]
+
+****************************************************************
+
+From: Pascal Pignard
+Sent: Sunday, November 24, 2019  5:13 AM
+
+[From private mail.]
+
+Annex "E.4.2 Example of Use of a Remote Access-to-Class-Wide Type", I've found:
+
+5       with Tapes, Name_Server;
+        package body Tape_Driver is
+           type New_Tape is new Tapes.Tape with ...
+           procedure Copy
+            (From, To : access New_Tape; Num_Recs: in Natural) is
+           begin
+             . . .
+           end Copy;
+           procedure Rewind (T : access New_Tape) is
+           begin
+              . . .
+           end Rewind;
+
+Shouldn't Copy and Rewind specifications added before bodies?
+Like:
+           type New_Tape is new Tapes.Tape with ...
+           procedure Copy
+            (From, To : access New_Tape; Num_Recs: in Natural);
+           procedure Rewind (T : access New_Tape);
+
+           procedure Copy
+            (From, To : access New_Tape; Num_Recs: in Natural) is
+           begin
+             . . .
+           end Copy;
+           procedure Rewind (T : access New_Tape) is
+           begin
+              . . .
+           end Rewind;
+
+****************************************************************
+
+From: Randy Brukardt
+Sent: Sunday, November 24, 2019  6:37 PM
+
+That's not necessary. The body of a subprogram can act as a specification, 
+including for overriding an inherited subprogram. It *is* necessary to 
+override both before freezing the type, and a body freezes everything declared 
+ahead of it, so you can override exactly one routine with a body.
+Thus, *one* of these routines needs a specification, but not both. Probably 
+if we were to update these, we should also add overriding indicators on the 
+routines to make it clearer what's going on.
+
+****************************************************************
+
+From: Pascal Pignard
+Sent: Monday, November 25, 2019  2:59 PM
+
+Exactly, I get the following error with GNAT:
+aarm_202x_chae.adb:59:17: overriding of "Rewind" is too late
+aarm_202x_chae.adb:59:17: spec should appear immediately after the type
+
+Thus I agree only Rewind specification is necessary but I thought that adding
+both was more compliant with Ada style ;-)
 
 ****************************************************************

Questions? Ask the ACAA Technical Agent