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,ca20ac98709f9b4a X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!34g2000hsh.googlegroups.com!not-for-mail From: mockturtle Newsgroups: comp.lang.ada Subject: Re: Array of Strings Date: Sun, 28 Sep 2008 06:01:33 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <0e021c61-535a-4935-95ad-2a241fa7302f@e53g2000hsa.googlegroups.com> <2VaCk.356477$yE1.321489@attbi_s21> <5a8cb0df-b16a-45d0-a03e-146ebea83e4d@d77g2000hsb.googlegroups.com> <0faf40a8-aac2-42ed-a536-1cc5a9c5d819@8g2000hse.googlegroups.com> NNTP-Posting-Host: 79.1.175.247 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1222606893 8399 127.0.0.1 (28 Sep 2008 13:01:33 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 28 Sep 2008 13:01:33 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 34g2000hsh.googlegroups.com; posting-host=79.1.175.247; posting-account=9fwclgkAAAD6oQ5usUYhee1l39geVY99 User-Agent: G2/1.0 X-HTTP-UserAgent: Opera/9.27 (Windows NT 5.1; U; it),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:2118 Date: 2008-09-28T06:01:33-07:00 List-Id: jedivaughn ha scritto: > This is going to be a long post but hopefully I'll make myself clearer > this time. I finally got everything set up in my package and it works > just fine. however one of the operations that I'm trying to do on the > package is an append. after appending to the list I want to make sure > the list is still in order. so I have to make comparisons with the < > or > operators. however, ada give's me the error: "final.adb:22:34: > there is no applicable operator ">" for private type "Element_Type" > defined at final.ads:3." > > Here is my package's .ads file > > generic > > type Element_Type is private; -- everything in the list is of this > type > type range_array is (<>); -- the index of the array is of this > type > > package final is (snip) You must tell to the compiler that comparison is defined for the type you are going to use for Element_Type since the compiler does not know that you are going to use strings as Element_Type (for example, you could use for Element_Type some "record" which has no "natural" comparison operator). You declare that Element_Type has comparison operators by adding after the "type Element_Type..." with function ">"(left, right : Element_Type) return Boolean is <>; Few remarks: 1. I have no Ada compiler at hand, so I cannot 101% grant that the line above is correct, although I would be surprised if it wasn't. 2. It is not necessary that the function parameters have name "left" and "right" (quite obvious) 3. The "is <>" tells the compiler to use as default any visible ">" operator with the required interface. This allows you to use the package with strings without esplicitely specifying the comparison operator. My answer is necessarly brief. If you want more details, I suggest to [brace yourself :-) and] have look to chapter 12 (especially section 12.6 "Formal subprograms") of the [ mytical/beloved/behated, choose one] reference manual http://www.adaic.com/standards/05rm/html/RM-TTL.html