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-12 05:21:15 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!194.42.224.136!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: Thu, 12 Apr 2001 15:15:45 +0200 Organization: (Posted via) GTS Netcom - Public USENET Service http://pubnews.netcom.net.uk Sender: ayende@softhome.net Message-ID: <9b46dr$cd8$1@taliesin.netcom.net.uk> References: <9b1oe1$i4m$1@taliesin.netcom.net.uk> NNTP-Posting-Host: diup-180-178.inter.net.il X-Trace: taliesin.netcom.net.uk 987077884 12712 213.8.180.178 (12 Apr 2001 12:18:04 GMT) X-Complaints-To: abuse@corp.netcom.net.uk NNTP-Posting-Date: Thu, 12 Apr 2001 12:18:04 +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:6813 Date: 2001-04-12T15:15:45+02:00 List-Id: wrote in message news:zJ7B6.11026$ix4.8084250@news1.rdc1.sfba.home.com... > >I've just started to learn Ada, and I've some problem solving some problems. > If you are learning in a course, asking the instructor will be much > faster than asking here. Assuming you are trying to learn just from > a book: I'm learning from a book. > >Here is the error: > >bintree.adb: Error: line 43 col 25 LRM:8.4(1), Binary operator ">" between > Without seeing line 43 (or any lines) of bintree.adb it's a little > hard to see what's going on, but, as the compiler suggests, a "use" > or "use type" might be what you need. Here is the line: if current.sorted_by > sort then What does use type does? How do I use it? > >procedure insert(insert_this : in data_type; Sort : in sort_by) is > >Here is the error this line produce: > >bintree.adb: Error: line 107 col 12 LRM:3.11.1(7), subprogram body is a > >homograph of another subprogram which does not require a completion, > That sounds like you have two different "insert" subroutines which > look the same in calling parameters so if the compiler saw > insert(a,b); > it wouldn't know which one to call. Yes, I found & fixed it, thanks. > >bintree.adb: Error: line 150 col 18 LRM:3.10.2(23&31), The prefix to 'ACCESS > >must be either an aliased view of an object or denote a subprogram with a > Like the message says, the thing before 'access must be aliased. Given > type node is record > Data : Data_type; > ... > type node_access is access all Node; > ... > result : node_access ... > ... result.data'access; > you see that "result.data" is defined as not aliased. Try > Data : aliased Data_type; That solved the problem, but why? What does aliased mean? > >Also I've a trouble using Root variable in a function that is undefied in > Is the Root variable defined before the function that uses it? Yes, it's defined here: type Binary_Tree is new Ada.Finalization.controlled with record root: Node_access := null; end record; Which is on the ads file, and other functions doesn't seem to have trouble finding it. The only thing I can think of is that this doesn't work because the function is not declared on the ads file.