Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Child Packa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 5643 of 5828
Post > Topic >>

Re: Child Package Operator Visibility

by Adam Beneschan <adam@[EMAIL PROTECTED] > Apr 7, 2008 at 08:03 AM

On Apr 5, 7:19 am, "(see below)" <yaldni...@[EMAIL PROTECTED]
> wrote:
> On 05/04/2008 15:03, in article
> L-udnRBPxNSpGWranZ2dnUVZ_gKdn...@[EMAIL PROTECTED]
 "pakman"
>
> <pakman...@[EMAIL PROTECTED]
> 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
 




 7 Posts in Topic:
Child Package Operator Visibility
"pakman" <pa  2008-04-05 10:03:27 
Re: Child Package Operator Visibility
"(see below)" &  2008-04-05 15:19:17 
Re: Child Package Operator Visibility
Adam Beneschan <adam@[  2008-04-07 08:03:44 
Re: Child Package Operator Visibility
"(see below)" &  2008-04-07 18:30:40 
Re: Child Package Operator Visibility
Robert A Duff <bobduff  2008-04-13 16:16:34 
Re: Child Package Operator Visibility
Jean-Pierre Rosen <ros  2008-04-14 09:42:21 
Re: Child Package Operator Visibility
Anh Vo <anhvofrcaus@[E  2008-04-07 08:25:50 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 14:37:39 CDT 2008.