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=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dbf84a1c2794f4fb X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: packages and private parts Date: 1997/02/14 Message-ID: <3304E195.275C@watson.ibm.com>#1/1 X-Deja-AN: 218878488 References: <32F1A8AD.6D6C@ehs.ericsson.se> <32FA579B.2496@watson.ibm.com> Content-Type: text/plain; charset=us-ascii Organization: IBM Thomas J. Watson Research Center Mime-Version: 1.0 Reply-To: ncohen@watson.ibm.com Newsgroups: comp.lang.ada X-Mailer: Mozilla 3.0 (Win95; I) Date: 1997-02-14T00:00:00+00:00 List-Id: 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