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,f37364fd74b84042 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!1g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Child Package Operator Visibility Date: Mon, 7 Apr 2008 08:03:44 -0700 (PDT) Organization: http://groups.google.com Message-ID: <6b08d1d0-1896-4951-8528-e11bef196dd7@1g2000prf.googlegroups.com> References: NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1207580628 3772 127.0.0.1 (7 Apr 2008 15:03:48 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 7 Apr 2008 15:03:48 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 1g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20865 Date: 2008-04-07T08:03:44-07:00 List-Id: On Apr 5, 7:19 am, "(see below)" wrote: > On 05/04/2008 15:03, in article > L-udnRBPxNSpGWranZ2dnUVZ_gKdn...@comcast.com, "pakman" > > wrote: > > Recently, in the process of illustrating Ada 95 child packages in a course I > > teach, I implemented the Fractions.Comparisons package from N. Cohen's Ada > > as a Second Language, 2nd ed text. In the test program, I withed the > > Fractions and Fractions.Comparisons packages, and then specified the use > > type Fractions.Fraction_Type for direct visibility of the Fractions package > > operators. I was surprised that the Fractions.Comparisons package operators > > were not directly visible (that is, I was not able to test for A < B). To > > make the example work, I added the use Fractions.Comparisons statement. > > > So, my questions are: 1) Why didn't the use type work for the > > Fractions.Comparisons operators, and 2) how do I make the operators directly > > visible? > > (1) Because the operations in Fractions.Comparisons are not primitive > operations of the fraction type. > > (2) Redesign the package structure (abolish Fractions.Comparisons) so that > the comparisons are primitive. Or just "use Fractions.Comparisons"? I don't actually have this book, so I'm just making a guess as what might work. In fact, this sort of thing is an idiom I used to use a lot, before Ada 95 gave us "use type". I would declare a package with the types I wanted to declare, and then define a nested package Operators which redefined all the operator symbols on those types using renaming, so that another package could say "use Pkg.Operators" without having to "use Pkg" which would make too much visible. -- Adam