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,93590e6c825ce084 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Thu, 06 Jul 2006 17:49:30 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: using interface types: guru assistance begged Date: Thu, 6 Jul 2006 17:50:14 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-x5ys3gIukW1aU8opxiGfhmGk9l5OUemy7vBEN7nwi2/M7mw8OiEwK78HvHIkrSCudzEa4PdCXNvb2ua!aReS44of3BbyDVk2UpC1QjoBLJR0H2fvt785LYUXR5uClxVeO1zbEaiwK8kqZXXKYxsUHvWVPJAd!JNHmGB0NKKNhHQ== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:5544 Date: 2006-07-06T17:50:14-05:00 List-Id: "(see below)" wrote in message news:C0D2E8C5.586FF%yaldnif.w@blueyonder.co.uk... > I am trying to learn how to use Ada 2005's interface types, > using GNAT GPL 2006 on MacOS X, > with an example along the following lines (much trimmed): ... > As written this compiles and runs correctly. If it does, I'd be amazed. You define something called "a_set", and then a bit later do various operations on "a_word_set" which is never defined anywhere. My original guess was that you forgot to change some names. But then, you define an operation returning "a_word_set": function bit (candidate : a_member_type) return a_word_set; which is not abstract. So if "a_word_set" was changed to "a_set", this would be illegal. At this point, I gave up; that's only the first package and a quick glance at the others doesn't make it any clearer. Please repost your code that really does compile... Even so, I can give you a very quick answer: > However, I would prefer the derivation of a_word_set to be private, thus: ... > And so on, for all of the subprograms declared in generic_word_masks. > Can anyone tell me what I am doing wrong here, and whether there is > any way to achieve the desired information hiding? I didn't look at the error messages; probably you need to make sure that you are declaring an abstract type in the instance. But in any case, the quick answer is no. Ada 2005 requires that interfaces are never hidden. The way interfaces work is that they are a property of a type: either it has that interface property or it does not. In particular, it is not possible for a type to have the same interface twice. But, if you could hide interfaces, you'd have to break privacy by looking into the private part in order to determine whether it was OK to add an interface to the type. (If you didn't do that, you could add the same interface twice, with different operations defined each time. Then, if dispatched on Interface'Class(), which operation would be called? It would be very hard to tell.) So Ada 2005 does not allow hiding of interfaces; all of the interfaces used in the full view also have to be used on the private view. (They don't necessarily have to have the same names, just the same set of interfaces.) Rules of thumb: * If you need hiding, use abstract tagged types; * If you need concrete operations or components in the root type, use abstract tagged types; * If you need multiple inheritance (more than one parent), use interfaces; * If you need to complete the type with tasks or protected types, use interfaces; * If you need to do a combination of the above, you're s**t out of luck. ;-) Randy.