!ASIS Issue #066 !topic Root and universal types in ASIS !reference ASIS 95-16.7, 3.11.13 !from Sergey Rybin !keywords A_Root_Type_Definition Corresponding_Root_Type semantic queries !discussion What should be returned by Asis.Definitions.Corresponding_Root_Type (its definition is appended to this comment) in the following situation: type My_Int is range -100 .. 100; type My_New_Int is new My_Int; ^^^^^^^^^^^ | Elem What should be the result of Corresponding_Root_Type (Elem): the declaration of My_Int or the artificial declaration of the root_integer type? RM95 3.5.4 (14) says: A type defined by an integer_type_definition is implicitly derived from root_integer, an anonymous predefined (specific) integer type, whose base range is System.Min_Int .. System.Max_Int. However, the base range of the new type is not inherited from root_integer, but is instead determined by the range or modulus specified by the integer_type_definition. Integer literals are all of the type universal_integer, the universal type (see 3.4.1) for the class rooted at root_integer, allowing their use with the operations of any integer type. It gives the formal background for returning the definition of root_integer. From the other side, returning the definition of the user-defined type My_Int seems to be much more useful from an application's viewpoint. And the definition of Corresponding_Root_Type does not give the final answer. I think, that the clarification comments should be added to Corresponding_Root_Type. My opinion is that this function should not return definition of root integer types. Another problem is that the ASIS says nothing about how the types of Root_Type_Kinds may be obtained. I think some clarification comments should be added. ------------------------------------------------------------------------------ -- Section 16.7 function Corresponding_Root_Type ------------------------------------------------------------------------------ function Corresponding_Root_Type (Type_Definition : in Asis.Type_Definition) return Asis.Declaration; ------------------------------------------------------------------------------ -- Type_Definition - Specifies the derived_type_definition to query -- -- This function recursively unwinds all type derivations and subtyping to -- arrive at a full_type_declaration that is neither a derived type or a -- subtype. -- -- Appropriate Type_Kinds: -- A_Derived_Type_Definition -- A_Derived_Record_Extension_Definition -- -- Returns Declaration_Kinds: -- An_Ordinary_Type_Declaration -- A_Task_Type_Declaration -- A_Protected_Type_Declaration -- A_Formal_Type_Declaration -- !resolution Accepted, with Modifications. !date 97-03-25 !Notes Two queries needed clarification with respect to implicit root/universal types: Asis.Declarations.Names and Asis.Definitions.Corresponding_Root_Type. In Subclause 15.1, Asis.Declarations.Names, the following was added: -- Returns Nil_Element_List for A_Declaration Elements representing the -- (implicit) declarations of universal and root numeric type (that is, -- if Type_Kind (Type_Declaration_View (Declaration)) = A_Root_Type_Definition. In addition, the commentary for Subclause 16.7, Asis.Definitions.Corresponding_Root_Type was changed as follows: --------------------------------------------------------------------------------------- -- Type_Definition - Specifies the derived_type_definition to query -- -- This function recursively unwinds all type derivations and subtyping to -- arrive at a full_type_declaration that is neither a derived type nor a -- subtype. -- -- In case of numeric types, this function always returns some user-defined -- type, not an implicitly defined root type corresponding to -- A_Root_Type_Definition. The only ways to get implicitly declared numeric -- root or universal types are to ask for the type of a universal expression -- or from the parameter and result profile of a predefined operation working -- with numeric types. ... See also Issue #062. Changes were made in ASIS version 2.0.M.