CVS difference for ai22s/ai22-0053-1.html

Differences between 1.2 and version 1.3
Log of other versions for file ai22s/ai22-0053-1.html

--- ai22s/ai22-0053-1.html	2023/01/13 03:06:05	1.2
+++ ai22s/ai22-0053-1.html	2023/03/23 07:47:03	1.3
@@ -1,24 +1,22 @@
-<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><title>AI22-0053-1/02</title>
+<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><title>AI22-0053-1/03</title>
 <style type="text/css">
 table td,table th{padding:0}
-.c11{border-right-style:solid;padding:5pt 5pt 5pt 5pt;border-bottom-color:#000000;border-top-width:0pt;border-right-width:0pt;border-left-color:#000000;vertical-align:top;border-right-color:#000000;border-left-width:0pt;border-top-style:solid;background-c
olor:#f0f0f0;border-left-style:solid;border-bottom-width:0pt;width:468pt;border-top-color:#000000;border-bottom-style:solid}
-.c18{border-spacing:0;border-collapse:collapse;margin-right:auto}
-.c19{background-color:#ffffff;max-width:468pt;padding:72pt 72pt 72pt 72pt}
-.c14{height:0pt}
+BODY.body{background-color:#ffffff; max-width:468pt; padding:72pt 72pt 72pt 72pt}
 P.head{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0; padding-top:0pt; color:#000000; font-size:14pt; padding-bottom:0pt; font-family:"Arial","Liberation Sans",sans-serif; line-height:1.15; orphans:2; widows:2; text-align:left; font-weight:
400; text-decoration:none; vertical-align:baseline; font-style:normal}
 H2.head{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0; padding-top:12pt; color:#000000; font-size:14pt; padding-bottom:6pt; font-family:"Arial","Liberation Sans",sans-serif; line-height:1.15; page-break-after:avoid; orphans:2; widows:2; tex
t-align:left; font-weight:400; text-decoration:none; vertical-align:baseline; font-style:normal}
 P.inst{margin-bottom:0; margin-top:0; margin-left:18pt; margin-right:0; padding-top:9pt; color:#000000; font-size:12pt; padding-bottom:6pt; font-family:"Arial","Liberation Sans",sans-serif;line-height:1.15; orphans:2; widows:2; text-align:left; font-weigh
t:400; text-decoration:none; vertical-align:baseline; font-style:normal}
 P.word{margin-bottom:0; margin-top:0; margin-left:36pt; margin-right:0; padding-top:0pt; color:#000000; font-size:11pt; padding-bottom:3pt; font-family:"Times New Roman","Times",serif; line-height:1.15; orphans:2; widows:2; text-align:left; font-weight:40
0; text-decoration:none; vertical-align:baseline; font-style:normal}
 P.wrds{margin-bottom:0; margin-top:0; margin-left:36pt; margin-right:0; padding-top:0pt; color:#000000; font-size:11pt; padding-bottom:12pt; font-family:"Times New Roman","Times",serif; line-height:1.15; orphans:2; widows:2; text-align:left; font-weight:4
00; text-decoration:none; vertical-align:baseline; font-style:normal}
-P.codt{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0; padding-top:0pt; color:#000000; font-size:10pt; padding-bottom:0pt; font-family:"Courier New",monospace; line-height:1.15; text-align:left; background-color:#f0f0f0; font-weight:400; tex
t-decoration:none; vertical-align:baseline; font-style:normal}
+P.codb{margin-bottom:0; margin-top:0; margin-left:12pt; margin-right:0; padding-left:4pt; padding-top:4pt; color:#000000; font-size:10pt; padding-bottom:4pt; font-family:"Courier New",monospace; line-height:1.15; text-align:left; background-color:#f0f0f0;
 font-weight:400; text-decoration:none; vertical-align:baseline; font-style:normal}
 P.text{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0; padding-top:0pt; color:#000000; font-size:11pt; padding-bottom:0pt; font-family:"Arial","Liberation Sans",sans-serif; line-height:1.15; text-align:left; font-weight:400; text-decoration:
none; vertical-align:baseline; font-style:normal}
 P.txts{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0; padding-top:0pt; color:#000000; font-size:11pt; padding-bottom:11pt; font-family:"Arial","Liberation Sans",sans-serif; line-height:1.15; text-align:left; font-weight:400; text-decoration
:none; vertical-align:baseline; font-style:normal}
 P.inds{margin-bottom:0; margin-top:0; margin-left:24pt; margin-right:0; padding-top:0pt; color:#000000; font-size:11pt; padding-bottom:11pt; font-family:"Arial","Liberation Sans",sans-serif; line-height:1.15; text-align:left; font-weight:400; text-decorat
ion:none; vertical-align:baseline; font-style:normal}
-P.a0{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0;color:#000000;font-size:26pt;font-family:"Arial","Liberation Sans",sans-serif; padding-top:0pt; padding-bottom:3pt; line-height:1.15; page-break-after:avoid; orphans:2; widows:2; text-align
:left; font-weight:400; text-decoration:none; vertical-align:baseline; font-style:normal}
+P.l3h{margin-bottom:0; margin-top:0; margin-left:0; margin-right:0;color:#000000;font-size:26pt;font-family:"Arial","Liberation Sans",sans-serif; padding-top:0pt; padding-bottom:3pt; line-height:1.15; page-break-after:avoid; orphans:2; widows:2; text-alig
n:left; font-weight:400; text-decoration:none; vertical-align:baseline; font-style:normal}
+SPAN.k5w{background-color:#f1c232}
 </style>
-</head><body class="c19 doc-content"><p class="a0">AI22-0053-1</p>
+</head><body class="body"><p class="l3h">AI22-0053-1</p>
 <p class="head">!standard 4.5.2(13) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
-&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;23-01-12 &nbsp;AI22-0053-1/02</p>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;23-03-23 &nbsp;AI22-0053-1/03</p>
 <p class="head">!standard 4.5.2(15/5)</p>
 <p class="head">!class binding interpretation 22-10-27</p>
 <p class="head">!status work item 22-10-27</p>
@@ -30,56 +28,56 @@
 <h2 class="head">!summary</h2>
 <p class="text">If an untagged record type overrides &quot;=&quot; in a private part, that
 overriding equality is</p>
-<p class="text">used for all calls to &quot;=&quot;.</p>
+<p class="text">used for all calls to &quot;=&quot;, unless they are within the immediate scope of
+the type and precede the overriding declaration</p>
 <h2 class="head">!issue</h2>
 <p class="txts">Suppose you have an untagged record type declared (completely; no partial view) in
 the visible part of a package and an overriding equality operator for it declared in the private
 part. At one point, that was illegal. AI12-0101-1 made it legal, but failed to adjust the dynamic
 semantics, illustrated by the example below.</p>
 
-<a id="t.5ab16c8b7a98812da7c224f726771c74077b44e3"></a><a id="t.0"></a><table class="c18"><tr class="c14"><td class="c11">
-<p class="codt"><b>procedure</b> Test53 <b>is</b><br>
- &nbsp; <b>pragma</b> Assertion_Policy (Check);<br>
+<p class="codb"><b>procedure</b> Test53 <b>is</b><br>
+&nbsp; &nbsp;<b>pragma</b> Assertion_Policy (Check);<br>
 <br>
- &nbsp; <b>package</b> Pkg <b>is</b><br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>type</b> Untagged_Rec <b>is</b> <b>record</b><br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X, Y : Integer;<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>end</b> <b>record</b>;<br>
+&nbsp; &nbsp;<b>package</b> Pkg <b>is</b><br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>type</b> Untagged_Rec <b>is</b> <b>record</b><br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;X, Y : Integer;<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>end</b> <b>record</b>;<br>
 <br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>type</b> Tagged_Rec <b>is</b> <b>tagged</b> <b>record</b><br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; X, Y : Integer;<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>end</b> <b>record</b>;<br>
- &nbsp; <b>private</b><br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>function</b> &quot;=&quot; (L, R : Untagged_Rec)
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>type</b> Tagged_Rec <b>is</b> <b>tagged</b> <b>record</b><br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;X, Y : Integer;<br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>end</b> <b>record</b>;<br>
+&nbsp; &nbsp;<b>private</b><br>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>function</b> &quot;=&quot; (L, R : Untagged_Rec)
 <b>return</b> Boolean <b>is</b> (L.X = R.X);<br>
- &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<b>function</b> &quot;=&quot; (L, R : Tagged_Rec) <b>return</b>
+&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <b>function</b> &quot;=&quot; (L, R : Tagged_Rec) <b>return</b>
 Boolean <b>is</b> (L.X = R.X);<br>
- &nbsp; <b>end</b> Pkg;<br>
- &nbsp; <b>use</b> Pkg;<br>
- &nbsp; <br>
- &nbsp; U1 : <b>constant</b> Untagged_Rec := (0, 111);<br>
- &nbsp; U2 : <b>constant</b> Untagged_Rec := (0, 222);<br>
- &nbsp; T1 : <b>constant</b> Tagged_Rec := (0, 111);<br>
- &nbsp; T2 : <b>constant</b> Tagged_Rec := (0, 222);<br>
+&nbsp; &nbsp;<b>end</b> Pkg;<br>
+&nbsp; &nbsp;<b>use</b> Pkg;<br>
+&nbsp; &nbsp;<br>
+&nbsp; &nbsp;U1 : <b>constant</b> Untagged_Rec := (0, 111);<br>
+&nbsp; &nbsp;U2 : <b>constant</b> Untagged_Rec := (0, 222);<br>
+&nbsp; &nbsp;T1 : <b>constant</b> Tagged_Rec := (0, 111);<br>
+&nbsp; &nbsp;T2 : <b>constant</b> Tagged_Rec := (0, 222);<br>
 <br>
- &nbsp; U_Eq : <b>constant</b> Boolean := U1 = U2;<br>
- &nbsp; T_Eq : <b>constant</b> Boolean := T1 = T2;<br>
+&nbsp; &nbsp;U_Eq : <b>constant</b> Boolean := U1 = U2;<br>
+&nbsp; &nbsp;T_Eq : <b>constant</b> Boolean := T1 = T2;<br>
 <br>
- &nbsp; <b>type</b> U_Wrapper <b>is</b> <b>record</b> F : Untagged_Rec; <b>end</b>
+&nbsp; &nbsp;<b>type</b> U_Wrapper <b>is</b> <b>record</b> F : Untagged_Rec; <b>end</b>
 <b>record</b>;<br>
- &nbsp; <b>type</b> T_Wrapper <b>is</b> <b>record</b> F : Tagged_Rec; &nbsp; <b>end</b>
+&nbsp; &nbsp;<b>type</b> T_Wrapper <b>is</b> <b>record</b> F : Tagged_Rec; &nbsp; <b>end</b>
 <b>record</b>;<br>
 <br>
- &nbsp; Uw_Eq : <b>constant</b> Boolean := U_Wrapper&#39;(F =&gt; U1) = (F =&gt; U2);<br>
- &nbsp; Tw_Eq : <b>constant</b> Boolean := T_Wrapper&#39;(F =&gt; T1) = (F =&gt; T2);<br>
+&nbsp; &nbsp;Uw_Eq : <b>constant</b> Boolean := U_Wrapper&#39;(F =&gt; U1) = (F =&gt; U2);<br>
+&nbsp; &nbsp;Tw_Eq : <b>constant</b> Boolean := T_Wrapper&#39;(F =&gt; T1) = (F =&gt; T2);<br>
 <b>begin</b><br>
- &nbsp; -- 3 out of 4 dentists recommend user-defined equality<br>
- &nbsp; <b>pragma</b> Assert (<b>not</b> U_Eq);<br>
- &nbsp; <b>pragma</b> Assert (T_Eq);<br>
- &nbsp; <b>pragma</b> Assert (Uw_Eq);<br>
- &nbsp; <b>pragma</b> Assert (Tw_Eq);<br>
+&nbsp; &nbsp;-- 3 out of 4 dentists recommend user-defined equality<br>
+&nbsp; &nbsp;<b>pragma</b> Assert (<b>not</b> U_Eq);<br>
+&nbsp; &nbsp;<b>pragma</b> Assert (T_Eq);<br>
+&nbsp; &nbsp;<b>pragma</b> Assert (Uw_Eq);<br>
+&nbsp; &nbsp;<b>pragma</b> Assert (Tw_Eq);<br>
 <b>end</b> Test53;</p>
-</td></tr></table><p class="text">&nbsp;</p>
+<p class="text">&nbsp;</p>
 <p class="text">The !discussion section for AI05-0123-1 very explicitly addresses this point:</p>
 <p class="inds">It would be pretty weird if the directly called equality didn&#39;t agree with the
 composed equality. For example, a call to the &quot;=&quot; operator for an untagged record type R
@@ -94,24 +92,37 @@
 definition of &quot;=&quot; everywhere (even where the overriding &quot;=&quot; is not
 visible).</p>
 
-<p class="text">Note that there are no partial views of anything in the preceding example, so
+<p class="txts">Note that there are no partial views of anything in the preceding example, so
 4.5.2(15/5) does not come into play at all.</p>
+
+<p class="text">Note that we also need to worry about a case where the untagged record type that
+defines its own &ldquo;=&rdquo; operator is derived from an ancestor that also overrode the
+predefined &ldquo;=&rdquo; operator. &nbsp;At what point does the newly overridden operator take
+over the semantics of the inherited &ldquo;=&rdquo; operator? &nbsp;Clearly any new parameter names
+used in the newly overridden operator can only be used when the caller has visibility on the
+overriding. &nbsp;But the intent of this AI is that even when these new parameter names are not
+visible, a call on the still visible inherited operator (perhaps using named notation
+&ldquo;=&rdquo;(El =&gt; A, Are =&gt; B)) would nevertheless invoke the function body associated
+with the new overriding, while using the parameter names of the inherited &ldquo;=&rdquo;
+operator.</p>
 <h2 class="head">!recommendation</h2>
 <p class="text">(See Summary.)</p>
 <h2 class="head">!wording</h2>
 <p class="inst">Add after 4.5.2(13):</p>
 
-<p class="wrds">For a record type, after the first freezing point of the type, predefined equality
-is defined in terms of the primitive equals operator of the type.</p>
+<p class="wrds">For an untagged record type, when outside the immediate scope of the type, any call
+on a primitive equals operator conformant with the profile of the predefined equals operator of the
+type, will invoke the body associated with the corresponding primitive equals operator visible at
+the end of the immediate scope of the type. </p>
 
 <p class="wrds">[Author&#39;s Note: Type extensions already have a separate rule in 4.5.2(14/3),
 and we have the private type rule in 4.5.2(15/3). It seems to make the most sense to have this new
 rule be separate and precede the existing rules.]</p>
 
-<p class="word">AARM Reason: Hidden overriding of &quot;=&quot; is used for all predefined equality
-operators &nbsp;of the type, so that composition works sensibly. We say &quot;after the first
-freezing point of the type&quot; so that a squirreling rename can be used to make the actual
-predefined equality visible if that is needed.</p>
+<p class="word">AARM Reason: A hidden overriding of &quot;=&quot; is used for all equality
+operators conformant to predefined equality &nbsp;of the type, so that composition works sensibly.
+We say &quot;outside the immediate scope of the type&quot; so that a squirreling rename can be used
+to make the actual predefined equality visible if that is needed.</p>
 <h2 class="head">!discussion</h2>
 <p class="txts">There are two ways to fix this problem.</p>
 
@@ -121,11 +132,10 @@
 mistake. Thus we rejected that alternative.</p>
 
 <p class="txts">The other option is to add a rule like 4.5.2(15/5) that applies in this case. This
-is OK as we do not allow overriding (of anything) after the type is frozen. This fixes the problem
-without creating a new (compile-time) incompatibility, but it does create a new inconsistency (a
-runtime incompatibility). In particular, existing client code would now get the (hidden) overriding
-&quot;=&quot; rather than the predefined &quot;=&quot;. AI12-0101-1 argues fairly persuasively that
-this inconsistency is most likely fixing a bug.</p>
+fixes the problem without creating a new (compile-time) incompatibility, but it does create a new
+inconsistency (a runtime incompatibility). In particular, existing client code would now get the
+(hidden) overriding &quot;=&quot; rather than the predefined &quot;=&quot;. AI12-0101-1 argues
+fairly persuasively that this inconsistency is most likely fixing a bug.</p>
 
 <p class="txts">The proposed rule only hides predefined equality after the freezing point of a
 type. Any attempt to call equals will freeze the associated type, so this does not cause any
@@ -144,6 +154,24 @@
 <p class="text">expected results.</p>
 <h2 class="head">!appendix</h2>
 <p class="txts">This issue was originally raised by Steve Baird privately. </p>
+
+<hr><p class="txts">&nbsp;</p>
+
+<p class="txts">Comment from Tucker Taft, March 23, 2023, 12:06 AM</p>
+
+<p class="txts">The third paragraph of the !discussion started:</p>
+
+<p class="txts">The other option is to add a rule like 4.5.2(15/5) that applies in this case.
+<span class="k5w">This is OK as we do not allow overriding (of anything) after the type is
+frozen.</span><span class="k5w"> </span></p>
+
+<p class="txts">The highlighted (second) sentence is only true for tagged types. &nbsp;We allow
+overriding of primitives of non-tagged types even after they are frozen (see 13.14(16)).</p>
+
+<p class="txts">The offending sentence was deleted.</p>
+
+<p class="text">[Editor&rsquo;s note: When the associated text was deleted, this useful comment
+disappeared, too, so I moved it down here.]</p>
+<hr><p class="txts">&nbsp;</p>
 
-<p class="text">*******************************************************************************</p>
 </body></html> 

Questions? Ask the ACAA Technical Agent