From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ac5c3bc59168d76 X-Google-Attributes: gid103376,public From: ncohen@watson.ibm.com (Norman H. Cohen) Subject: Re: Subprogram Renaming Date: 1996/04/11 Message-ID: <4kjhg2$139s@watnews1.watson.ibm.com>#1/1 X-Deja-AN: 146955931 distribution: world references: <316AEA8D.7600@csehp3.mdc.com> <4kgde6$q8t@watnews1.watson.ibm.com> organization: IBM T.J. Watson Research Center reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada Date: 1996-04-11T00:00:00+00:00 List-Id: In article <4kgde6$q8t@watnews1.watson.ibm.com>, I wrote: |> This capability is especially |> useful when a subprogram is implemented using generic instantiation. Renaming-as-body is also useful in conjunction with derived subprograms. Here's a variation on my previous example: package Integer_Dequeues is type Dequeue_Type is private; procedure Add_To_Front (Dequeue: in out Dequeue_Type; Item: in Integer); procedure Add_To_Back (Dequeue: in out Dequeue_Type; Item: in Integer); procedure Remove_From_Front (Dequeue: in out Dequeue_Type; Item: out Integer); procedure Remove_From_Back (Dequeue: in out Dequeue_Type; Item: out Integer); private type Dequeue_Type is ...; end Integer_Dequeues; with Integer_Dequeues; package Integer_Stacks is type Stack_Type is private; procedure Push (Stack: in out Stack_Type; Item: in Integer); procedure Pop (Stack: in out Stack_Type; Item: out Integer); private use Integer_Dequeues; type Stack_Type is new Dequeue_Type; procedure Push (Stack: in out Stack_Type; Item: in Integer) renames Add_To_Front; procedure Pop (Stack: in out Stack_Type; Item: out Integer) renames Remove_From_Front; end Integer_Stacks; The subprograms being renamed are the inherited subprograms procedure Remove_From_Front (Dequeue: in out Stack_Type; Item: out Integer); procedure Remove_From_Back (Dequeue: in out Stack_Type; Item: out Integer); implicitly declared after the derived-type declaration in the private part. Because a renaming declaration acting as a subprogram declaration is allowed in the package declaration, Integer_Stacks does not even need a package body! -- Norman H. Cohen ncohen@watson.ibm.com