From: Jonas Nygren <ehsjony@ehs.ericsson.se>
Subject: Re: Subprogram Renaming
Date: 1996/04/12
Date: 1996-04-12T00:00:00+00:00 [thread overview]
Message-ID: <316E12F2.37BC@ehs.ericsson.se> (raw)
In-Reply-To: 4kjhg2$139s@watnews1.watson.ibm.com
Norman H. Cohen wrote:
>
> 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:
I have been experimenting with such a construct for some months but always
encountered some new problem. My example code is similar to Normans but
instead of Integer_Dequeues I have Generic_Dequeues and Generic_Stacks.
My problem is how to handle a subprogram with the same name for Dequeue_Type
and Stack_Type, e.g. Remove_All. I never managed to figure out how to handle
the renaming. Perhaps somebody here can help me.
I intersperse the added code in Normans example below.
Of course I could introduce a dummy type with the common names marked
to distinguish them from the intended name. Deque_Type and Stack_Type
then derives from this 'dummy type'.
Another note: As mentioned above my code uses generics while Norman's does
not. Is there a catch? I encountered a problem with Gnat where it worked
without generics but not with. I have reported it but have not heard anything
from ACT (I am not on support contract :-). Is there Ada legal problems
with adding generics to these example packages?
/jonas
>
> 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);
procedure Remove_All (Dequeue: in out Dequeue_Type);
> 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);
procedure Remove_All (Stack: in out Stack_Type);
> 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;
procedure Remove_All (Stack: in out Stack_Type)
renames Remove_All; -- Does not work,
-- Gnat e.g. creates a recursive call (reported)
> 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
--
-------------------------------------------------------
-- Jonas Nygren
-- ehsjony@ehs.ericsson.se
-------------------------------------------------------
next prev parent reply other threads:[~1996-04-12 0:00 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <md5:FE4AB546A8392541EDC1E3FE12E3D8AF>
1996-04-09 0:00 ` Subprogram Renaming James A. Squire
1996-04-09 0:00 ` Robert Dewar
1996-04-10 0:00 ` Robert A Duff
1996-04-11 0:00 ` Mark A Biggar
1996-04-10 0:00 ` johndoe
1996-04-10 0:00 ` Norman H. Cohen
1996-04-11 0:00 ` Norman H. Cohen
1996-04-12 0:00 ` Jonas Nygren [this message]
1996-04-12 0:00 ` Norman H. Cohen
1996-04-13 0:00 ` Robert A Duff
1996-04-15 0:00 ` Norman H. Cohen
[not found] <md5:3CC2294B6049DDBD8790280EABCEDE81>
1996-04-12 0:00 ` James A. Squire
[not found] <md5:88A5E8822105A2023A0A951BB5EC646E>
1996-04-10 0:00 ` James A. Squire
[not found] <md5:87494FB95037B9578F62831DE10B6BB3>
1996-04-10 0:00 ` James A. Squire
[not found] <md5:95D854EBD1A47E0E86027A3CC7DBD9A4>
1996-04-10 0:00 ` James A. Squire
1996-04-10 0:00 ` Robert Dewar
1996-04-11 0:00 ` Jonas Nygren
1996-04-11 0:00 ` Robert Dewar
1996-04-12 0:00 ` Jonas Nygren
1996-04-10 0:00 ` Robert A Duff
1996-04-11 0:00 ` Adam Beneschan
1996-04-11 0:00 ` Robert Dewar
1996-04-11 0:00 ` Robert A Duff
1996-04-10 0:00 ` johndoe
[not found] <md5:046A59600C3FEFC327385C3E914D6997>
1996-04-08 0:00 ` James A. Squire
1996-04-08 0:00 ` Robert Dewar
1996-04-09 0:00 ` Gary McKee
1996-04-09 0:00 ` Robert A Duff
[not found] <md5:C24D8C2EE138D9627FB8B93E2E35D9F3>
1996-04-05 0:00 ` James A. Squire
1996-04-06 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox