!ASIS Issue #083
!topic Normalized generic association questions
!reference  ASIS 95
!from  Sergey Rybin 97-10-16
!keywords generic associated normalized
!discussion

I have two questions concerning the normalized generic associations.
May be, it would be better to send two separate messages, but all the
preliminary explanations needed to ask these questions are the same.

So, consider the following piece of the Ada code:

procedure Test is                                             -- 1
   type T is range -100 .. 100;                               -- 2
   procedure Deault_Proc (I : Integer) is                     -- 3
   begin                                                      -- 4
      null;                                                   -- 5
   end Deault_Proc;                                           -- 6
                                                              -- 7
   generic                                                    -- 8
      type Form_T is range <>;                                -- 9
      with procedure Form_Proc (I : Integer) is Deault_Proc;  --10
      with function "+" (L, R : T) return T is <>;            --11
   package Gen_Pack is                                        --12
   end Gen_Pack;                                              --13
                                                              --14
   package Inst_Pack is new Gen_Pack (T);                     --15
begin                                                         --16
   null;                                                      --17
end Test;                                                     --18


Let's get the Generic_Actual_Part from the insatntiation in the line
15 with Normalized => True, and let's decompose further the second
component of the result (which gives an example of well-defined
situation) and the third components of the results (which raises
questions).

First, what do we have as a result of Generic_Actual_Part?
It should look like:

  (Form_T    => T,
   Form_Proc => Default_Proc,
   "+"       => ??? --<-- and what should be here ??)

Now, let's apply Actual_Parameter. For the second component we should
get the name (expression) Default_Proc from the line 10, and its
Enclosing_Element should be the corresponding
A_Formal_Procedure_Declaration element, just as explained in the
definition of Asis.Expressions.Actual_Parameter for normalized
generic associations. Right? Fine! And now let's apply
Actual_Parameter to the third association. And here are two
questions:

QUESTION 1:

What *should* happen, if an ASIS implementation does not support the
implicit predefined operations? Should we get Nil_Element? I think,
this is the only reasonable interpretation. If so, it should be
stated in the documentation.

QUESTION 2:

Suppose we have a "good" implementation, which does support implicit
predefined operations (in fact, this even is not important, we can
just add the explicit declaration of the "+" function for T in this
example). What should be returned by Actual_Parameter? Should it be
the declaration of the (explicit or implicit) declaration of the
corresponding "+" function? But Actual_Parameter can return only
An_Expression results. We do not have any (naming) expression
representing this "+" function at all in this example, but we have a
normalized generic association with this "+" as an actual. And what
should be an Enclosing_Element for the result?

!resolution  Accept
!date 98-03-26
!Notes

For clause 15.45, Asis.Declarations.Generic_Actual_Part, replace:

-- Each normalized association represents a one on one mapping of a
-- generic_formal_parameter_declaration to the explicit or default expression
-- or name.  A normalized association has one A_Defining_Name component that
-- denotes the generic_formal_parameter_declaration, and one An_Expression
-- component that is either the explicit_generic_actual_parameter, or a
-- default_expression or default_name.

with:

-- Each normalized association represents a one-on-one mapping of a
-- generic_formal_parameter_declaration to the explicit or default expression
-- or name.  A normalized association has:
--   - one A_Defining_Name component that denotes the
--     generic_formal_parameter_declaration, and
--   - one An_Expression component that is either:
--     o  the explicit_generic_actual_parameter,
--     o  a default_expression, or
--     o  a default_name from the generic_formal_parameter_declaration or
--        an implicit naming expression which denotes the actual subprogram
--        selected at the place of instantiation for a formal subprogram
--        having A_Box_Default.

For clause 17.22, Asis.Expressions.Actual_Parameter, correct:

--  - The Enclosing_Element of the An_Expression element is the
--    parameter_specification or generic_formal_parameter_declaration that
--    contains the default_expression or default_name.

to:

--  - The Enclosing_Element of the An_Expression element is the
--    parameter_specification or generic_formal_parameter_declaration that
--    contains the default_expression or default_name, except for the case when
--    this An_Expression element is an implicit naming expression
--    representing the actual subprogram selected at the place of the
--    instantiation for A_Box_Default.  In the latter case, the Enclosing_Element
--    for such An_Expression is the instantiation.

For clause 13.33, Asis.Elements.Is_Part_of_Implicit, correct:

-- Reference Manual 6.4(9)     - Implicit actual parameter expressions (defaults).
--                             - The A_Parameter_Association that includes a defaulted
--                               parameter value Is_Normalized and also
--                               Is_Part_Of_Implicit.  The Formal_Parameter and the
--                               Actual_Parameter values from such Associations are not
--                               Is_Part_Of_Implicit unless they are from default
--                               initializations for an inherited subprogram declaration
--                               and have an Enclosing_Element that is the parameter
--                               specification of the subprogram declaration. (Those
--                               elements are shared with (were created by) the original
--                               subprogram declaration.)
--                             - All A_Parameter_Association Kinds from a Normalized
--                               list are Is_Part_Of_Implicit.

to:

-- Reference Manual 6.4(9)     - Implicit actual parameter expressions (defaults).
--             and 12.3(7)     - The A_Parameter_Association that includes a defaulted
--                               parameter value Is_Normalized and also
--                               Is_Part_Of_Implicit.  The Formal_Parameter and the
--                               Actual_Parameter values from such Associations are not
--                               Is_Part_Of_Implicit unless they are from default
--                               initializations for an inherited subprogram declaration
--                               and have an Enclosing_Element that is the parameter
--                               specification of the subprogram declaration. (Those
--                               elements are shared with (were created by) the original
--                               subprogram declaration, or they are naming
--                               expressions representing the actual generic
--                               subprogram selected at the place of an instantiation for
--                               A_Box_Default.)
--                             - All A_Parameter_Association Kinds from a Normalized
--                               list are Is_Part_Of_Implicit.
