!ASIS Issue #096 !topic Normalized associations for call-as-dereference and dispatching calls !reference ASIS 95 !from Sergey Rybin 98-06-13 !keywords normalized associations dispatching calls dereference calls !discussion Suppose we have: type Acc_Subprogram is access procedure (I : Integer); Dynamic_Call : Acc_Subprogram; procedure P1 (J : Integer) is begin null; end P1; procedure Q1 (K : Integer) is begin null; end Q1; Var : Integer := 13; begin Dynamic_Call := P1'access; Dynamic_Call.all (Var); -<<-------------------------------------- ^^^^^^^^^^^^^^^^^^^^^^ | | Dynamic_Call := Q1'access; | Dynamic_Call.all (Var); -<<-------------------------------------+ ^^^^^^^^^^^^^^^^^^^^^^ | | And suppose we have got _NORMALIZED_ parameter associations from these calls. The question is - what should be the result of the Formal_Parameter query applied to such normalized associations? Clearly, it cannot be formal parameter defining names corresponding to the formal parameters of actually called procedures - this information is dynamically-determined in a general case. The only reasonable choice would be to return the defining name I from the declaration of the access-to-subprogram type Acc_Subprogram. The questions are: 1. Is it really what should be returned in this case (we've discussed this with Alain, and both of us think, that it is. 2. Should this be clarified in the ASIS definition? I'm pretty sure, that it should, because as it stands now, ASIS just reuses the old Ada83-based approach for normalized subprogram associations, without taking into account call-as-dereference and dispatching calls. Dispatching calls was the next question, and I'm afraid, it is not so easy to resolve. Suppose we've got a normalized subprogram association from a dispatching call (quite a syntactic action). And what in this case should be the result of the Formal_Parameter query applied to such an association? Alain's suggestion is to return a formal parameter defining name from the subprogram declaration corresponding to the root of the type hierarchy. Any comments? And this also should be documented in the ASIS definition. !resolution Accept. !date 98-07-29 To Clause 17.30, Function_Call_Parameters, change the paragraph reading: -- The exception ASIS_Inappropriate_Element is raised when the function -- call is an attribute reference. To: -- If the prefix of the call denotes an access to a function implicit or -- explicit deference, normalized associations are constructed on the basis -- of the formal_part of the parameter_and_result_profile from the -- corresponding access_to_subprogram definition. -- Returns Nil_Element for normalized associations in the case where -- the called function can be determined only dynamically (dispatching -- calls). ASIS cannot produce any meaningful result in this case. -- The exception ASIS_Inappropriate_Element is raised when the function -- call is an attribute reference and Is_Normalized is True. To Clause 18.26, Call_Statement_Parameters, change the paragraph reading: -- The exception ASIS_Inappropriate_Element is raised when the function -- call is an attribute reference. To: -- If the prefix of the call denotes an access to a procedure implicit or -- explicit deference, normalized associations are constructed on the basis -- of the formal_part of the parameter_profile from the corresponding -- access_to_subprogram definition. -- Returns Nil_Element for normalized associations in the case where -- the called procedure can be determined only dynamically (dispatching -- calls). ASIS cannot produce any meaningful result in this case. -- The exception ASIS_Inappropriate_Element is raised when the procedure -- call is an attribute reference and Is_Normalized is True.