From rybin@possum.srcc.msu.su Tue Jun 17 11:25:38 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id LAA11721; Tue, 17 Jun 1997 11:25:37 -0400 Received: from mail.acm.org by ida.org (4.1/SMI-4.1) id AA10638; Tue, 17 Jun 97 11:25:48 EDT Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us [199.75.54.2]) by mail.acm.org (8.8.5/8.7.5) with ESMTP id LAA1374756; Tue, 17 Jun 1997 11:25:23 -0400 Received: from crocus.gamma.ru by sw-eng.falls-church.va.us (8.7.1/) id PAA21847; Tue, 17 Jun 1997 15:22:11 GMT Received: from srcc.UUCP (uucp@localhost) by crocus.gamma.ru (8.8.5/8.7.3) with UUCP id TAA13548; Tue, 17 Jun 1997 19:25:13 +0400 (MSD) Received: by gamma.srcc.msu.su; Tue, 17 Jun 1997 19:24:40 +0400 Received: by possum.srcc.msu.su (UUPC/@ v5.09gamma, 14Mar93); Tue, 17 Jun 1997 19:10:50 +0400 To: asis-comment@sw-eng.falls-church.va.us Cc: asis-technical@sw-eng.falls-church.va.us Message-Id: Organization: Information Systems, SRCC, MSU From: "Sergey I. Rybin" Date: Tue, 17 Jun 97 19:10:50 +0400 X-Mailer: BML [MS/DOS Beauty Mail v.1.36] Subject: Calls to recursive generic subprograms in generic bodies Lines: 134 Content-Length: 5281 Status: OR !topic Corresponding_Called_* and generic recursive subprograms !reference ASIS 95- 18.25, 17.29 !from Sergey Rybin !keywords generic recursive subprogram !discussion What should be returned by Corresponding_Called_Function/Correponding_Called_Entity in case of a recursive subprogram call in the body of a generic recursive subprogram: generic function Factorial (I : Integer) return Integer; function Factorial (I : Integer) return Integer is begin if I = 1 then return 1; else return I * Factorial (I - 1); -- ^^^^^^^^^^^^^^^^^^ ?????? end if; end Factorial; The only reasonable thing to return is the declaration of the generic function Factorial, but Corresponding_Called_Function does not have A_Generic_Function_Declaration in the list of returned kinds. SUGGESTION : A_Generic_Function_Declaration should be added to the list of the ---------- returned Element kinds for Corresponding_Called_Function, and A_Generic_Procedure_Declaration should be added to the list of the returned Element kinds for Corresponding_Called_Function to make it possible to process (recursive) calls of the recursive generic subprograms in generic bodies. Any opinions? Sergey Rybin. --------------------------------------------------------------------------- --------------------------------------------------------------------------------------- -- 17.29 function Corresponding_Called_Function --------------------------------------------------------------------------------------- function Corresponding_Called_Function (Expression : in Asis.Expression) return Asis.Declaration; --------------------------------------------------------------------------------------- -- Expression - Specifies the function_call to query -- -- Returns the declaration of the called function. -- -- Returns a Nil_Element if the: -- -- - function_prefix denotes a predefined operator for which the implementation -- does not provide an artificial function declaration, -- -- - prefix of the call denotes an access to a function implicit or explicit -- dereference, -- -- - argument is a dispatching call. -- -- If function_prefix denotes an attribute_reference, and if the corresponding -- attribute is (re)defined by an attribute definition clause, an implementation -- is encouraged, but not required, to return the definition of the corresponding -- subprogram whose name is used after "use" in this attribute definition -- clause. If an implementation cannot return such a subprogram definition, a -- Nil_Element should be returned. For an attribute reference which is not -- (re)defined by an attribute definition clause, a Nil_Element should be returned. -- -- Appropriate Expression_Kinds: -- A_Function_Call -- -- Returns Declaration_Kinds: -- Not_A_Declaration -- A_Function_Declaration -- A_Function_Body_Declaration -- A_Function_Body_Stub -- A_Function_Renaming_Declaration -- A_Function_Instantiation -- A_Formal_Function_Declaration -- --|IP Implementation Permissions: --|IP --|IP An implementation can choose whether or not to construct and provide --|IP artificial implicit declarations for predefined operators. -- --------------------------------------------------------------------------------------- -- 18.25 function Corresponding_Called_Entity --------------------------------------------------------------------------------------- function Corresponding_Called_Entity (Statement : in Asis.Statement) return Asis.Declaration; --------------------------------------------------------------------------------------- -- Statement - Specifies the procedure_call_statement or -- entry_call_statement to query -- -- Returns the declaration of the procedure or entry denoted by the call. -- -- Returns a Nil_Element if the: -- -- - prefix of the call denotes an access to a procedure implicit -- or explicit dereference, -- -- - argument is a dispatching call, -- -- - argument is a call to a dispatching operation of a tagged type which -- is not statically determined. -- -- If procedure_prefix denotes an attribute_reference, and if the corresponding -- attribute is (re)defined by an attribute definition clause, an implementation -- is encouraged, but not required, to return the definition of the corresponding -- subprogram whose name is used after "use" in this attribute definition -- clause. If an implementation cannot return such a subprogram definition, a -- Nil_Element should be returned. For an attribute reference which is not -- (re)defined by an attribute definition clause, a Nil_Element should be returned. -- -- Appropriate Statement_Kinds: -- An_Entry_Call_Statement -- A_Procedure_Call_Statement -- -- Returns Declaration_Kinds: -- Not_A_Declaration -- A_Procedure_Declaration -- A_Procedure_Body_Declaration -- A_Procedure_Body_Stub -- A_Procedure_Renaming_Declaration -- A_Procedure_Instantiation -- A_Formal_Procedure_Declaration -- An_Entry_Declaration -- --------------------------------------------------------------------------------------- From rybin@possum.srcc.msu.su Wed Aug 20 15:15:06 1997 Return-Path: Received: from ida.org by cronus.csed.ida.org (SMI-8.6/SMI-SVR4) id PAA19634; Wed, 20 Aug 1997 15:15:05 -0400 Received: from mail.acm.org by ida.org (4.1/SMI-4.1) id AA27225; Wed, 20 Aug 97 15:16:03 EDT Received: from sw-eng.falls-church.va.us (ns1.sw-eng.falls-church.va.us [199.75.54.2]) by mail.acm.org (8.8.5/8.7.5) with ESMTP id PAA1132202; Wed, 20 Aug 1997 15:13:36 -0400 Received: from crocus.gamma.ru by sw-eng.falls-church.va.us (8.7.1/) id TAA08667; Wed, 20 Aug 1997 19:11:51 GMT Received: from srcc.UUCP (uucp@localhost) by crocus.gamma.ru (8.8.5/8.7.3) with UUCP id XAA07861 for asis-comment@sw-eng.falls-church.va.us; Wed, 20 Aug 1997 23:14:54 +0400 (MSD) Received: by gamma.srcc.msu.su; Wed, 20 Aug 1997 23:14:09 +0400 Received: by possum.srcc.msu.su (UUPC/@ v5.09gamma, 14Mar93); Wed, 20 Aug 1997 23:13:52 +0400 To: asis-comment@sw-eng.falls-church.va.us Message-Id: Organization: Information Systems, SRCC, MSU From: "Sergey I. Rybin" Date: Wed, 20 Aug 97 23:13:51 +0400 X-Mailer: BML [MS/DOS Beauty Mail v.1.36] Subject: recursive call in generic body Lines: 49 Content-Length: 1518 Status: OR !topic recursive calls of generic subprograms !reference ASIS 95- 17.29, 18.25 !from Sergey Rybin !keywords generics, recyrsion !discussion Consider the following example of the recursive call of a generic subprogram in the generic body: procedure Test is generic type Int is range <>; function Factorial (N : Int) return Int; function Factorial (N : Int) return Int is begin if N < 0 then raise Constraint_Error; elsif N = 0 then return 1; else return N * Factorial (N-1); -- ^^^^^^^^^^^^^^^ <- Corresponding_Called_Function ?? end if; end Factorial; begin null; end Test; The question is - what should be returned by the call to Corresponding_Called_Function, if its argument is the recursive call to a function declared by generic function declaration? (The corresponding function is treated as an instance in the generic body, but it does not help in case of ASIS - we have neither A_Generic_Function_Declaration in the list of returned kinds for Corresponding_Called_Function, nor an A_Function_Declaration Element in this Compilation Unit. This shows, that there is a hole in the definition of Corresponding_Called_Function/Corresponding_Called_Entity in case of recursive calls in generic bodies. I would suggest to add A_Generic_Function_Declaration/A_Generic_Procedure_Declaration to the lists of the returned kinds (with corresponding comments in the documentation) to fix this hole. Any comments? Sergey