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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, WEIRD_PORT autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7eaf9f2597de2259 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-10-10 03:17:59 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!newsfeeds.belnet.be!news.belnet.be!fr.usenet-edu.net!usenet-edu.net!enst!enst.fr!not-for-mail From: Francisco Javier Loma Daza Newsgroups: comp.lang.ada Subject: Re: on package naming, should the word "_pkg" be part of it? Date: Wed, 10 Oct 2001 12:17:05 +0200 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: <9pif1o01btl@drn.newsguy.com> <3BBD12F1.9BED0B70@acm.org> <3BC0B1D4.21C79A8@acm.org> <3bc1d137.20930256@news.demon.co.uk> <3bc3ffb5.826258@news.demon.co.uk> <3bc40fef.1827097@news.demon.co.uk> Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit X-Trace: avanie.enst.fr 1002709078 38324 137.194.161.2 (10 Oct 2001 10:17:58 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Wed, 10 Oct 2001 10:17:58 +0000 (UTC) To: comp.lang.ada@ada.eu.org Return-Path: In-Reply-To: <3bc40fef.1827097@news.demon.co.uk> X-Mailer: Spruce 0.7.4 for X11 w/smtpio 0.8.2 X-Virus-Scanned: by AMaViS perl-11 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.4 Precedence: bulk X-Reply-To: Francisco.Loma@isotrol.com List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , List-Archive: Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:14136 Date: 2001-10-10T12:17:05+02:00 On Wed, 10 Oct 2001, john.mccabe@emrad.com.nospam (John McCabe) wrote: > Date: Wed, 10 Oct 2001 09:47:04 GMT > To: comp.lang.ada@ada.eu.org > From: john.mccabe@emrad.com.nospam (John McCabe) > Reply-To: comp.lang.ada@ada.eu.org > Sender: comp.lang.ada-admin@ada.eu.org > Subject: Re: on package naming, should the word "_pkg" be part of it? > > On Wed, 10 Oct 2001 08:04:10 GMT, john.mccabe@emrad.com.nospam (John > McCabe) wrote: > > Francisco > > I've just been reminded of where the problem lies with respect to the > use of Object as a 'class' name (with thanks to Martin Ellerker). > > Consider the following Parent and Child classes (similar to what I > mentioned in my earlier message): > > File: GParent.ads > ----------------- > generic > package GParent is > type Object is abstract tagged null record; > end GParent; > > File: GParent-GChild.ads > ------------------------ > with GParent; > generic > package GParent.GChild is > type Object is new GParent.Object with null record; > end GParent.GChild; > > Separate library level instantiations are provided as follows: > > File: IParent.ads > ----------------- > with GParent; > package IParent is new GParent; > > File: IChild.ads > ---------------- > with IParent; > with GParent.GChild; > package IChild is new IParent.GChild; > > So far so good. A test program as follows compiles and runs without > error (unless I've typed something in wrongly) > > File: TestG.adb > --------------- > with IChild; > procedure TestG is > begin > null; > end TestG; > > > Now, however, if you then have a third level of Generic class, say.. > > File: GParent-GChild-GGChild.ads > -------------------------------- > with GParent.GChild; > generic > package GParent.GChild.GGChild is > type Object is new GParent.GChild.Object with null record; > end GParent.GChild.GGChild; > > and instantiate it with: > > File: IGChild.ads > ----------------- > with IChild; > with GParent.GChild.GGChild; > package IGChild is new IChild.GGChild; > > and change the test program to: > > File: TestG.adb > --------------- > with IGChild; -- Change to IGChild from IChild. > procedure TestG is > begin > null; > end TestG; > > we get the error: > > igchild.ads:3:01: instantiation error at gparent-gchild-ggchild.ads:4 > igchild.ads:3:01: "GChild" not declared in "IParent". > > The cause of this is the explicit reference in line 4 of > GParent-GChild-GGChild.ads to GParent.GChild.Object. Since IChild is > the instantiation of GChild, it is IChild that, at this point, > declares the GGChild 'class' we're interested in, not GParent.GChild. > > We could attempt to use the child-to-parent visibility rules to allow > use to change GParent.Object and GParent.GChild.Object into just > Object and Object, but then the scoping rules cause problems with > errors: > > gparent-gchild.ads:4:24: object "Object" cannot be used before end of > its declaration > gparent-gchild-ggchild.ads:4:24: object "Object" cannot be used before > end of its declaration > > So there you go. > I would use the following to desambiguate -- with GParent.GChild; -- this is not needed generic package GParent.GChild.GGChild is type Object is new GChild.Object with null record; end GParent.GChild.GGChild; That is the schema I actually use. For anothe level of genericity generic package GParent.GChild.GGChild.GGGChild is type Object is new GGChild.Object with null record; subtype Class is Object'Class; type Handle is access all Object'Class; type Pointer is access all Object; --another useful (sometimes) trick package Parent renames GGChild; -- and then use Parent.Object to call parent methods end; and so for.