comp.lang.ada
 help / color / mirror / Atom feed
From: "(see below)" <yaldnif.w@blueyonder.co.uk>
Subject: Re: Child Package Operator Visibility
Date: Sat, 05 Apr 2008 15:19:17 +0100
Date: 2008-04-05T15:19:17+01:00	[thread overview]
Message-ID: <C41D48F5.E2FDD%yaldnif.w@blueyonder.co.uk> (raw)
In-Reply-To: L-udnRBPxNSpGWranZ2dnUVZ_gKdnZ2d@comcast.com

On 05/04/2008 15:03, in article
L-udnRBPxNSpGWranZ2dnUVZ_gKdnZ2d@comcast.com, "pakman"
<pakman744@nospam.com> 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
<surname><forename> chez blueyonder.co.uk





  reply	other threads:[~2008-04-05 14:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-05 14:03 Child Package Operator Visibility pakman
2008-04-05 14:19 ` (see below) [this message]
2008-04-07 15:03   ` Adam Beneschan
2008-04-07 15:25     ` Anh Vo
2008-04-07 17:30     ` (see below)
2008-04-13 20:16     ` Robert A Duff
2008-04-14  7:42       ` Jean-Pierre Rosen
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox