Version 1.8 of ais/ai-00196.txt

Unformatted version of ais/ai-00196.txt version 1.8
Other versions for file ais/ai-00196.txt

!standard 03.09.02 (17)          02-11-23 AI95-00196/03
!class binding interpretation 98-03-27
!status Amendment 200Y 02-10-23
!status ARG Approved 10-0-0 02-10-12
!status work item 01-10-08
!status received 98-03-27
!priority Low
!difficulty Easy
!subject Assignment and tag-indeterminate calls with controlling results
!summary
For the assignment of the result of a tag-indeterminate dispatching call to a target of a class-wide type, the controlling tag value for the call is defined by the tag of the target. This case is addressed by the addition of a rule following 3.9.2(18).
3.9.2(17-19) also applies to dispatching calls without controlling operands.
!question
The wording of 3.9.2(17), in the context of the preceding paragraphs, makes it unclear whether the definition of "controlling tag value" applies to a primitive function having no controlling operands.
Was 3.9.2(17) intended to mean "If all of the controlling operands (if any) are tag-indeterminate,..."? (Yes.)
Regardless of whether 3.9.2(17) includes calls to functions having no controlling operands, but having a controlling result, it appears that 3.9.2(19) conflicts with 5.2(9). The problem arises with any assignment whose expression is a call to a function having a tag-indeterminate controlling result.
Consider the following:
package P1 is type T is tagged null record; function Func return T; -- (1) end P1;
with P1; package P2 is use P1; type E is new T with null record; function Func return E; -- (2) end P2;
with P1; with P2; procedure Bummer is
Eee : P2.E ;
procedure Crash_and_Burn (Formal : in P1.T'Class) is Local : P1.T'Class := Formal; begin Local := P1.Func; -- (3) end Crash_and_Burn;
begin Crash_and_Burn (Eee); -- (4) end Bummer;
The tag-indeterminate call to func at (3) is in question. For the call at (4), what is the body that will execute when the call at (3) is made? 3.9.2(19) says it is P1.Func (declared at (1)), and 5.2(9) says that it is P2.Func (declared at (2)).
3.9.2(19) says that the controlling tag for the call is statically determined to be P1.T'Tag, because the call is not a controlling operand of another call, and P1.Func is a dispatching operation of type P1.T.
However, 5.2(9) contradicts this. The target (local) is class-wide, and the expression (call to P1.Func) is tag-indeterminate, so the controlling tag is taken from the tag of local, which is P2.E'Tag.
This dilemma arises when the expression of an assignment statement is a call on a function with a tag-indeterminate controlling result. How is this dilemma reconciled? (The call at (3) will invoke P2.Func.)
!recommendation
(See summary.)
!wording
Change 3.9.2(17) to read:
If all of the controlling operands (if any) are tag-indeterminate, then:
Insert a paragraph after 3.9.2(18) that reads:
If the call has a controlling result and is the (possibly parenthesized or qualified) expression of an assignment statement whose target is of a class-wide type, then its controlling tag value is determined by the target;
!discussion
Based on 5.2(9), it's clear that the controlling tag for a tag-indeterminate expression assigned to a class-wide target is intended to be determined by the tag of the target object. It was an oversight not to specify this case in 3.9.2.
It was also intended that the rules of 3.9.2(17-19) apply to a call to a dispatching operation which has a controlling result and no controlling operands. This is more in the nature of a confirmation, but might be made clearer by the addition of the phrase "if any" in 3.9.2(17), as occurs in the definition of tag-indeterminate names and expressions (cf. 3.9.2(6)).
!corrigendum 03.09.02(17)
Replace the paragraph:
If all of the controlling operands are tag-indeterminate, then:
by:
If all of the controlling operands (if any) are tag-indeterminate, then:
!corrigendum 03.09.02(18)
Insert after the paragraph:
the new paragraph:
!ACATS test
!appendix

!section 3.9.2(17)
!subject      assignment and tag-indeterminate calls with controlling results
!reference  RM95-3.9.2(17-19)
!reference  RM95-5.2(9)
!from       Dan Rittersdorf 97-09-15
!keywords   controlling tag, assignment, controlling result, no controlling operand
!reference 1997-15785.a Dan Rittersdorf 1997-9-15>>
!discussion

   Before addressing the assignment issue, my example begs another question.

   The language of 3.9.2(17), in the context of the preceding paragraphs,
   makes it unclear that the definition of "controlling tag value" applies
   to a primitive function having controlling operands.

   It can be presumed that 3.9.2(17) was intended to mean:

      "If all of the controlling operands (if any) are tag-indeterminate,..."
                                          ^^^^^^^^

   Without this clause applying to calls having no controlling operands,
   the "controlling tag value" would be left undefined for such calls.
   The lack of language specific to the case of a function having no
   controlling operands is conspicuous because it is explicitly mentioned in
   many other places in the same chapter.  The immediately preceding
   paragraphs discuss only functions having one or more controlling
   operands, and the working of 3.9.2(17) leads one to think that functions
   having no controlling operands are somehow left out of the definition
   of "controlling tag value".

   Regardless of whether 3.9.2(17) includes calls to functions having
   no controlling operands, but having a controlling result, it appears that
   3.9.2(19) is at odds with 5.2(9).

   To be honest, the matter of a call to a primitive function having no
   controlling operands isn't relevant to the contradiction of 3.9.2(19)
   and 5.2(9).  The problem arises with any assignment whose expression
   is a call to a function having a tag-indeterminate controlling result.

   Consider the following:

         package p1 is
            type t is tagged null record ;
            function func return t ;                  -- (1)
         end p1 ;

         with p1 ;
         package p2 is
            use p1 ;
            type e is new t with null record ;
            function func return e ;                  -- (2)
         end p2 ;

         with p1 ;
         with p2 ;
         procedure bummer_dude is
         --
            eee : p2.e ;

            procedure crash_and_burn (formal : in p1.t'class) is
               local : p1.t'class := formal ;
            begin
               local := p1.func ;                     -- (3)
            end crash_and_burn ;
         begin
            crash_and_burn (eee) ;                    -- (4)
         end bummer_dude ;

   The tag-indeterminate call to func at (3) is in question.  I am going
   to presume that 3.9.2(17) applies to func, but if it doesn't, I'm sure
   you can imagine that the call involves a function that has a
   tag-indeterminate controlling operand, and the problem remains.
   For the call at (4), what is the body that will execute when the call
   at (3) is made?  3.9.2(19) says it is p1.func (declared at (1)),
   and 5.2(9) says that it is p2.func (declared at (2)).

   3.9.2(19) says that the controlling tag for the call is statically
   determined to be p1.t'tag, because the call is not a controlling operand
   of another call, and p1.func is a dispatching operation of type p1.t.

   However, 5.2(9) contradicts this.  The target (local) is class-wide,
   and the expression (call to p1.func) is tag-indeterminate, so the
   controlling tag is taken from the tag of local, which is p2.e'tag.

   This dilemma arises when the expression of an assignment statement is a
   call on a function with a tag-indeterminate controlling result.
   How is this dilemma reconciled?

   Thanks.

--
  Dan.Rittersdorf@mail.ccur.com        or              RittersdorfD@ACM.org
______________________________________________________________________________
  Concurrent Computer Corporation      |               Daniel G. Rittersdorf
  2101 W. Cypress Creek Rd.            |               178 Washington Street
  Ft. Lauderdale FL 33309              |               Sparta, MI 49345-1324
  Ph: +1 (954) 974-1700                |               Ph: +1 (616) 887-5431
______________________________________________________________________________

****************************************************************

From: Gary Dismukes
Sent: Wednesday, June 19, 2002 1:48 AM

Here's a revision of AI-196 that revises the summary and adds text to
the !wording and !discussion sections (plus a small but semantically
significant correction to the first paragraph of the !question section).

I realize this may be too late to add to the agenda for the upcoming
meeting, but wanted to get this homework assignment out of the way.
Hope you all have a productive meeting this week and sorry that I
won't be able to join you.

[Editor's note: This is version 2.]

****************************************************************

Questions? Ask the ACAA Technical Agent