!standard 03.11 (09) 99-06-25 AI95-00064/07 !class binding interpretation 95-07-06 !status Corrigendum 2000 99-05-24 !status WG9 approved (8-0-0) 97-07-04 !status ARG approved (9-0-0) 97-04-11 !status work item (letter ballot was 10-1-1) 96-10-03 !status work item 96-06-14 (returned to ARG by WG9) !status ARG approved 8-0-2 (by letter ballot) 96-06-05 !status ARG approved (subject to editorial review) 8-0-2 95-11-01 !status received 95-07-06 !reference AI95-00135 !priority High !difficulty Hard !subject Elaboration checks for renamings-as-body !summary An elaboration check is performed for a call to a subprogram whose body is given as a renaming-as-body. This check fails if the renaming-as-body has not yet been elaborated. (As usual, an elaboration check is also performed for the renamed subprogram, and fails if *its* body has not yet been elaborated.) !question 3.11(10) indicates that an elaboration check is required only when a subprogram has an explicit body that is a subprogram_body. However, when a renaming declaration is used as a body, it is possible for the elaboration of the renaming declaration to require the evaluation of a name, such as X.all, that implies some sort of elaboration check should be performed. For example: function F return Integer; type Pointer_To_Func is access function return Integer; X : Pointer_To_Func := Q'Access; -- Presume Q already elaborated Y : Integer := F; -- We need some sort of elaboration check .... Z : Pointer_To_Func := X; function F return Integer renames Z.all; In the above, clearly we need to wait until the expression "Z.all" is evaluated before F can be safely called. However, it is not clear that any check for this is required by 3.11(10). By the way, where is "body" defined? It presumably includes entry body, and perhaps renaming-as-body. However, only the syntactic entity BODY is defined (in 3.11). Where is the unbolded term "body" defined? !recommendation (See summary.) !wording Define the term "body" to include the syntactic category body, plus entry_body, plus renaming-as-body, in 3.11.1(1). Change "subprogram_body" to "body" in 3.11(10). Add a paragraph before 8.5.4(8) to define the run-time semantics of renamings-as-body: For a call to a subprogram whose body is given as a renaming-as-body, the execution of the renaming-as-body is equivalent to the execution of a subprogram_body that simply calls the renamed subprogram with the same parameters. !discussion Since the elaboration of a renaming-as-body may evaluate expressions, it is clearly necessary that this elaboration be performed before calling the subprogram. Therefore, an elaboration check should be done on a subprogram whose body is a renaming-as-body, not just when the body is a subprogram_body. It seems that the right model for renaming-as-body that occurs after the subprogram is frozen should be that of a wrapper subprogram, with its own elaboration "bit." Taken together, these rules imply that when calling a subprogram whose body is a renaming-as-body, a check will be made that the renaming-as-body has been elaborated, and also that the body of the renamed subprogram has been elaborated. Furthermore, if the renamed subprogram is in turn completed by *another* renaming-as-body, the body of that third subprogram will also be checked; the rule is transitive. See AI95-00135 for a discussion of circularities involving renamings-as-body. !corrigendum 3.11.01(1) @drepl Declarations sometimes come in two parts. A declaration that requires a second part is said to @i. The second part is called the @i of the declaration (and of the entity declared), and is either another declaration, a body, or a pragma. @dby Declarations sometimes come in two parts. A declaration that requires a second part is said to @i. The second part is called the @i of the declaration (and of the entity declared), and is either another declaration, a body, or a pragma. A @i is a @fa, @fa, or a renaming-as-body (see 8.5.4). !corrigendum 3.11(10) @drepl @xindent is already elaborated. This check and the evaluations of any actual parameters of the call are done in an arbitrary order.> @dby @xindent !corrigendum 8.05.04(8) @dinsb For a call on a renaming of a dispatching subprogram that is overridden, if the overriding occurred before the renaming, then the body executed is that of the overriding declaration, even if the overriding declaration is not visible at the place of the renaming; otherwise, the inherited or predefined subprogram is called. @dinst For a call to a subprogram whose body is given as a renaming-as-body, the execution of the renaming-as-body is equivalent to the execution of a subprogram_body that simply calls the renamed subprogram with the same parameters. !ACATS test A test is needed. A C-Test should be built that checks cases similiar to the example in the question. The cases should include access to subprograms, and unelaborated regular subprograms, and verify that Program_Error is raised. !appendix !section 3.11(9) !section 8.5.4(1) !subject Renaming-as-body and elaboration !reference RM95 3.11(9,10) !reference RM95 8.5.4(1) !from Tucker Taft 95-07-05 !reference as: 95-5208.a Tucker Taft 95-7-5>> !discussion In 3.11(10), it indicates that an elaboration check is only required when a subprogram has an explicit body that is a subprogram_body. However, when a renaming declaration is used as a body, it is possible for the elaboration of the renaming declaration to require the evaluation of a name, such as X.all, that implies some sort of elaboration check should be performed. For example: function F return Integer; type Pointer_To_Func is access function return Integer; X : Pointer_To_Func := Q'Access; -- Presume Q already elaborated Y : Integer := F; -- We need some sort of elaboration check .... Z : Pointer_To_Func := X; function F return Integer renames Z.all; In the above, clearly we need to wait until "Z.all" is elaborated before calling F. However, it is not clear that any check for this is required by 3.11(10). It seems that the right model for renaming-as-body that occurs after the subprogram is frozen should be that of a wrapper subprogram, with its own elaboration "bit." By the way, where is "body" defined? It presumably includes entry body, and perhaps renaming-as-body. However, only the syntactic entity BODY is defined (in 3.11). Where is the unbolded term "body" defined? -Tuck **************************************************************** !section 03.11(09) !subject Call for letter ballot on AI95-00064 !reference AI95-00064/01 !from Norman Cohen 96-04-29 !reference 96-5524.a Norman H. Cohen 96-4-29>> !discussion I call for a letter ballot on AI-64 because I believe the elaboration check needs to be defined more precisely: Presumably, it is checked both that the renaming declaration has been elaborated and that the body of the renamed subprogram has been elaborated. (In addition, the AI should make it obvious that this check is performed at the time of a call.) I suggest that the !recommendation be rewritten in language that parallels 3.11(10) and 3.11(14): For a call to a (non-protected) subprogram that has a renaming-as-body, a check is made that the renaming declaration has already been elaborated, and that the body of the subprogram named in the renaming declaration has already been elaborated. This check and the evaluations of any actual parameters of the call are done in an arbitrary order. The exception Program_Error is raised if this check fails. (Perhaps just the first sentence will suffice as the !summary.) Can this be considered an editorial correction, and a revised version recirculated for letter ballot, before the next meeting? **************************************************************** !section 3.11(09) !subject Call for letter ballot on AI95-00064 !reference 03.11(09) !reference AI95-00064/01 !reference 96-5524.a Norman Cohen 96-04-29 !reference 96-5543.a Robert A Duff 96-5-8>> !discussion Norman says: > I call for a letter ballot on AI-64 because I believe the elaboration > check needs to be defined more precisely: Presumably, it is checked > both that the renaming declaration has been elaborated and that the > body of the renamed subprogram has been elaborated. (In addition, the > AI should make it obvious that this check is performed at the time of a > call.) > > I suggest that the !recommendation be rewritten in > language that parallels 3.11(10) and 3.11(14): > > For a call to a (non-protected) subprogram that has a > renaming-as-body, a check is made that the renaming declaration has > already been elaborated, and that the body of the subprogram named in > the renaming declaration has already been elaborated. This check and > the evaluations of any actual parameters of the call are done in an > arbitrary order. The exception Program_Error is raised if this check > fails. > > (Perhaps just the first sentence will suffice as the !summary.) I agree with Norm's complaint. However, I think the above wording fails to handle the transitive cases. If the body of P renames Q, and the body of Q renames R, and the body of R renames S, then we need to check that the bodies of all of P, Q, R, and S have been elaborated. The above wording only checks P and Q. I think a better solution is to add something like this to the !wording section: Add a paragraph before 8.5.4(8) to define the run-time semantics of renamings-as-body: The execution of a renaming-as-body is equivalent to the execution of a subprogram_body that simply calls the renamed subprogram with the same parameters. This makes the rule correctly transitive, and I think is more elegant anyway. > Can this be considered an editorial correction, and a revised version > recirculated for letter ballot, before the next meeting? Will do. By the way, I disagree that the !summary needs to be so precise. Everybody knows that elaboration checks are done at call sites, and the summary is supposed to be as simple as possible without being outright wrong. The !wording section, on the other hand, defines the precise rule (or it will, soon). (This is one AI that I thought was subtle enough that it deserved to have a wording section.) So, Norm, I suggest you read the new !wording when I send it out, and criticize *that* if you think it's still not right. - Bob ****************************************************************