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,LOTS_OF_MONEY autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad988eb0a9545c86 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-13 03:58:15 PST Path: supernews.google.com!sn-xit-03!supernews.com!freenix!grolier!dispose.news.demon.net!demon!diablo.netcom.net.uk!netcom.net.uk!not-for-mail From: "Ayende Rahien" Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. Date: Fri, 13 Apr 2001 13:54:52 +0200 Organization: (Posted via) GTS Netcom - Public USENET Service http://pubnews.netcom.net.uk Sender: ayende@softhome.net Message-ID: <9b6m27$68e$1@taliesin.netcom.net.uk> References: <9b46dr$cd8$1@taliesin.netcom.net.uk> <9b6jtu$4is$2@taliesin.netcom.net.uk> NNTP-Posting-Host: diup-180-204.inter.net.il X-Trace: taliesin.netcom.net.uk 987159437 6414 213.8.180.204 (13 Apr 2001 10:57:17 GMT) X-Complaints-To: abuse@corp.netcom.net.uk NNTP-Posting-Date: Fri, 13 Apr 2001 10:57:17 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.60.2296.0000 X-MimeOLE: Produced By Microsoft MimeOLE V5.60.2296.0000 Xref: supernews.google.com comp.lang.ada:6856 Date: 2001-04-13T13:54:52+02:00 List-Id: "chris.danx" wrote in message news:PDAB6.10174$FD1.1166748@news6-win.server.ntlworld.com... > Hi, > > > The error from Object Ada is: > > bintree.adb: Error: line 9 col 28 LRM:4.1(3), Direct name, root, is not > > visible, Ignoring future references > > > > The error from GNAT is: > > > > bintree.adb:9:42: "root" is undefined (more references follow) > > > > With nothing more to follow this. > > Ok, this means it's not found a definition for it. It doesn't know what or > where it is. You probably know that. > > [SNIP] > > > private > > type Binary_Tree is new Ada.Finalization.controlled with record > > root: Node_access := null; > > end record; > > the error comes because > > > package body binTree is > [snip] > > procedure insert(insert_this : in data_type; Sort : in sort_by) is > > New_node : Node_Access := new node; > > current : Node_access := root; -- This is the line it compline about!! > > you've forgot to that Root is in Binary_Tree. Okay, so how do I fix it? And what is wrong, anyway? > I have a question. From your code it doesn't look like an ADT. Is this > what you intended? I can't remember the term for what this looks like, but > I think it's to do with storing the Tree as a global variable in the package > not as an ADT. Okay, major cocept problem here. I'm coming here with C/C++ background, and I understand that Ada has a different OO paradigm. I assumed that for each Binary_Tree spesific type that I create, there would be its own Root. I mean: package Int_BinTree is new Binary_Tree(data_type=> Integer,Sort_by=>Integer); Bin_Tree_First, Bin_Tree_Second : Int_BinTree; Does Bin_Tree_First.Root = Bin_Tree_Second.Root ? > If you want an ADT you need to pass in a Binary_Tree type as necessary. I > didn't see it any where in your code so i'm assuming it's based on a global > variable. I think that you are talking about ADO vs ADT , right? generic abstract data type & generic abstract data object > There's nothing wrong doing it this way! Then why doesn't it compile?