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!news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "(see below)" Newsgroups: comp.lang.ada Subject: Re: Child Package Operator Visibility Date: Sat, 05 Apr 2008 15:19:17 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Trace: individual.net 65AJ8zWL2q3rztAnYEhpWg1FKLNQyMcRX3YWmMLcmlQhqDqAiS Cancel-Lock: sha1:IRWj9o6lSt6pkDz0Z8CCLyXoiag= User-Agent: Microsoft-Entourage/12.1.0.080305 Thread-Topic: Child Package Operator Visibility Thread-Index: AciXKAgSFg2zknPwYkK55v5vibftfg== Xref: g2news1.google.com comp.lang.ada:20840 Date: 2008-04-05T15:19:17+01:00 List-Id: On 05/04/2008 15:03, in article L-udnRBPxNSpGWranZ2dnUVZ_gKdnZ2d@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. Cohen is illustrating child packages here. The example should not be taken as a paradigm of good ADT methodology in Ada, because it is far from that. (Moreover, the comparison algorithm is excessively prone to overflow.) > > While this is an academic exercise, actual projects using this combination > of parent and child packages have experienced similar problems. Refactoring needed! -- Bill Findlay chez blueyonder.co.uk