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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns13feed!worldnet.att.net!attbi_s22.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" Organization: jrcarter at acm dot org User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: how to import a package 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> In-Reply-To: <1165846777.475130.199390@f1g2000cwa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 12.201.97.213 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s22 1165868896 12.201.97.213 (Mon, 11 Dec 2006 20:28:16 GMT) NNTP-Posting-Date: Mon, 11 Dec 2006 20:28:16 GMT Date: Mon, 11 Dec 2006 20:28:16 GMT Xref: g2news2.google.com comp.lang.ada:7892 Date: 2006-12-11T20:28:16+00:00 List-Id: markww wrote: > > procedure Add_Record(GenericData : PERSON_REC) is > Temp : gNode.Node_Ptr; > begin > > Temp := new gNode.Node; > Temp.Data := GenericData; > end Add_Record; This leaks memory. Others have discussed the solution to your specific problem, but I think what you're missing is the general mind-set that a type definition and the operations on that type should be encapsulated in a package. So far, you only have 1 operation (Add_Record), but in a generally useful linked-list package you'd probably have a lot more. Those operations should be in the package; then, whenever you instantiate the package, you get the operations. This concept, encapsulation of data and their operations (usually with hiding of the data's structure), is called "object orientedness". In many languages, this design concept is mixed up with the implementation concept of programming by extension (incorrectly called OOP); for example, in C++, you get both from the "class" construct. In Ada, the 2 are separate. At this point, you might find it instructive to look at some existing linked-list packages, such as the one in the Ada-0X container library, or the ones in the PragmAda Reusable Components http://pragmada.home.mchsi.com/ or many of the component libraries you can find at adapower.com or adaworld.com. -- Jeff Carter "Blessed is just about anyone with a vested interest in the status quo." Monty Python's Life of Brian 73