comp.lang.ada
 help / color / mirror / Atom feed
From: "Norman H. Cohen" <ncohen@watson.ibm.com>
Subject: Re: packages and private parts
Date: 1997/02/14
Date: 1997-02-14T00:00:00+00:00	[thread overview]
Message-ID: <3304E195.275C@watson.ibm.com> (raw)
In-Reply-To: E58onv.4zC@world.std.com


Robert A Duff wrote:

> >Unfortunately, the price for this is an annoying restriction (RM
> >10.1.1(16)) against declaring an ordinary package as a child of a
> >generic-package instance.
> 
> Why do you consider that restriction "annoying"?  I can't remember ever
> wanting to violate it...

It's annoying because it outlaws innocent and natural combinations of
what ought to be orthogonal language features.  It's quite reasonable
for a programmer to write something like

   package Dice is
      pragma Pure;
      subtype Die_Value is
         Integer range 1 .. 6;
   end Dice;

   with Dice;
   with Ada.Numerics.Discrete_Random;
   package Random_Dice is
      new Ada.Numerics.Discrete_Random
         ( Dice.Die_Value );

   package Random_Dice.Pair_Of_Dice is  -- ILLEGAL!
      subtype Pair_Value is
         Integer range 
            2*Die_Value'First .. 2* Die_Value'Last;
      function Random_Pair
        (Gen: Generator) return Pair_Value;
   end Random_Dice.Pair_Of_Dice;

Of course there are ways to program around this forbidden construct, but
why should I have to?  Yes, I know, the rule prohibiting Random_Dice
from having noninstance children ensures that a package whose name is
not of the form Ada.Numerics.Discrete_Random.* does not have visibility
into the private part of instances of Ada.Numerics.Discrete_Random.  But
that's a rather obscure consideration, of interest primarily to us
language lawyers, and probably the farthest thing from the mind of the
programmer who writes the code above and finds that it won't compile.

-- 
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen




  parent reply	other threads:[~1997-02-14  0:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <32F1A8AD.6D6C@ehs.ericsson.se>
     [not found] ` <E4wBxD.Jtp.0.-s@inmet.camb.inmet.com>
     [not found]   ` <32FA579B.2496@watson.ibm.com>
     [not found]     ` <E58onv.4zC@world.std.com>
1997-02-07  0:00       ` packages and private parts Mats Weber
1997-02-07  0:00       ` Mats Weber
1997-02-14  0:00       ` Norman H. Cohen [this message]
1997-02-16  0:00         ` Tucker Taft
1997-02-17  0:00           ` Norman H. Cohen
     [not found] <32F170C8.6A88F208@cam.org>
     [not found] ` <dewar.854838063@merv>
     [not found]   ` <32FA4C67.48D9@watson.ibm.com>
     [not found]     ` <32FB27FF.794BDF32@innocon.com>
1997-02-07  0:00       ` Tucker Taft
1997-02-08  0:00         ` Ken Garlington
     [not found]       ` <dewar.855326480@merv>
1997-02-10  0:00         ` Jeff Carter
1997-02-10  0:00           ` Larry Kilgallen
1997-02-10  0:00           ` Robert Dewar
     [not found]     ` <dewar.855276290@merv>
1997-02-07  0:00       ` Norman H. Cohen
1997-02-07  0:00         ` Robert Dewar
1997-02-14  0:00           ` Norman H. Cohen
1997-02-15  0:00             ` Robert Dewar
1997-02-10  0:00   ` Jon S Anthony
replies disabled

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