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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM 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!postnews.google.com!f1g2000cwa.googlegroups.com!not-for-mail From: "markww" Newsgroups: comp.lang.ada Subject: Re: how to import a package Date: 11 Dec 2006 06:19:37 -0800 Organization: http://groups.google.com Message-ID: <1165846777.475130.199390@f1g2000cwa.googlegroups.com> 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> NNTP-Posting-Host: 67.154.89.221 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1165846782 23858 127.0.0.1 (11 Dec 2006 14:19:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 11 Dec 2006 14:19:42 +0000 (UTC) In-Reply-To: <1165830005.15844.5.camel@localhost> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: f1g2000cwa.googlegroups.com; posting-host=67.154.89.221; posting-account=cNKOMg0AAADT2ug8oGSYYXo8bsDvrHzw Xref: g2news2.google.com comp.lang.ada:7888 Date: 2006-12-11T06:19:37-08:00 List-Id: Ok I just broke down and wrote the test function to take a specific PERSON_REC type to add into a new node. The program compiles and runs as expected, but I just lost my generics support by doing this, I think: procedure Add_Record(GenericData : PERSON_REC) is Temp : gNode.Node_Ptr; begin Temp := new gNode.Node; Temp.Data := GenericData; end Add_Record; So yes now it runs ok and I can print the contents of the linked list and see that a person record was added into the Data member. But now I can't use this Add_Record function to store some other type of user defined data, it will only work with PERSON_RECs. I'm sorry, I still don't understand how to just pass a generic through as a parameter! Thanks, Mark Georg Bauhaus wrote: > On Sun, 2006-12-10 at 22:50 -0800, markww wrote: > > So I made a test function like: > > > > procedure Add_Record(GenericData : gNode.T) is > > Temp : gNode.Node_Ptr; > > begin > > Temp := new gNode.Node; > > Temp.Data := GenericData; > > end Add_Record; > > > > now the compiler is saying that my generic type T is not visible to the > > rest of the application. > > The type T is in the formal part of the package, not in the package > proper. So either you are explicit about T (you have made an > instance of the package using Some_Type for T, so you can use > Some_Type instead of gNode.T there, too) or you make your generic > package have a type Gen_T by using "subtype Gen_T is T" or similar. > > > > Also, is this procedure definition correct? In C++ it's easy to do this > > after defining a type it would be just: > > > > bool Add_Record (T t); > > template > > bool CLinkedList::Add_Record(T t) > > { > > // ... > > } > > But here, you have one specific T and one generic T.