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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,910a48a538936849 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.germany.com!news.belwue.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: how to import a package Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1165371252.358817.57840@80g2000cwy.googlegroups.com> <4577dc92$1_1@glkas0286.greenlnk.net> <7ft8le.vk1.ln@hunter.axlog.fr> <1165817760.736164.218530@73g2000cwn.googlegroups.com> <1165819804.449958.305980@73g2000cwn.googlegroups.com> <1165830005.15844.5.camel@localhost> <1165846777.475130.199390@f1g2000cwa.googlegroups.com> Date: Mon, 11 Dec 2006 16:03:00 +0100 Message-ID: <4ahvv5zjwjhc$.17letwewzun6c$.dlg@40tude.net> NNTP-Posting-Date: 11 Dec 2006 16:03:00 CET NNTP-Posting-Host: 74ae609f.newsspool1.arcor-online.net X-Trace: DXC=T?GfEMLbYe8T2Rfi64Fo<]lROoR1^YC2XCjHcb9]QnSO56USP\b=VZVL8LM: X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:7889 Date: 2006-12-11T16:03:00+01:00 List-Id: On 11 Dec 2006 06:19:37 -0800, markww wrote: > I'm sorry, I still don't understand how to just pass a generic through > as a parameter! No way. It is incorrect in either C++ or Ada. A generic is never a [normal] parameter. It can only be a *generic* parameter of another generic thing. Answering less formally, what you want to achieve is probably this: generic type T is private; package Generic_List is type Node; type Node_Ptr is access Node; type Node is limited record -- We don't copy nodes Data : T; -- The data in the node Prev : Node_Ptr; -- Previous node, else null Next : Node_Ptr; -- Next node, else null end record; -- Operations defined on the nodes follow: -- -- Add a new node to the list after the node indicated by -- the parameter After. -- procedure Add (After : Node_Ptr; Data : T); end Generic_List; ---------------------------------------------- package body Generic_List is procedure Add (After : Node_Ptr; Data : T) is New_Node : Node_Ptr := new Node; begin New_Node.Data := Data; New_Node.Prev := After; New_Node.Next := After.Next; if After.Next /= null then After.Next.Prev := New_Node; end if; After.Next := New_Node; end Add; end Generic_List; ------------------------------------------- 1. T is a generic formal parameter of the package Generic_List. 2. Data is normal parameter of a procedure Add. 3. The procedure Add is not generic 4. When Generic_List is instantiated this instance will be a normal package with a normal procedure Add in it. 5. This Add will be defined on the actual type specified for T during the instantiation. For example: package List_Of_Integers is new Generic_List (T=>Integer); -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de