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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ad988eb0a9545c86 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-04-11 18:42:05 PST Path: supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!128.230.129.106!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Problem trying to implement generics. References: <9b1oe1$i4m$1@taliesin.netcom.net.uk> X-Newsreader: Tom's custom newsreader Message-ID: Date: Thu, 12 Apr 2001 01:41:51 GMT NNTP-Posting-Host: 24.20.190.201 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 987039711 24.20.190.201 (Wed, 11 Apr 2001 18:41:51 PDT) NNTP-Posting-Date: Wed, 11 Apr 2001 18:41:51 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: supernews.google.com comp.lang.ada:6795 Date: 2001-04-12T01:41:51+00:00 List-Id: >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 trying to put the defination of Node in the body, but it results in >compilation error, is there some way to put the defination in the body? Or >does it matter naught, because it's on the private part of the package? If Node is defined in the spec, the compiler needs to know things like how big it is to generate assignments, etc. Since the compiler cannot look at the body (which may not even be written yet), the full definition must be in the spec. It's OK in the private part, as you have it now. >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. >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. >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; >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? When the compiler gives you an error message, it means it is doesn't know what you want. Occasionally, that's because the compiler is stupid, but often, and in several of the cases above, there is no way even the most clever compiler could know what you want. So you need to let the compiler know things like "actually, there's only one 'procedure insert', Root is a variable I haven't told you about yet, I did mean for Data to be aliased, though I didn't say it, here's what Node looks like, so you can generate copying or comparing code."