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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c019ad9cc913bbe X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-13 19:34:15 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: Ada2005 temp solo child (was: Re: The Dreaded "Missing Subunits" Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Sat, 14 Sep 2002 02:33:44 GMT References: <1b585154.0209121449.ef12609@posting.google.com> <3D819EE7.3A69E5EB@praxis-cs.co.uk> NNTP-Posting-Host: shell01.theworld.com Organization: The World Public Access UNIX, Brookline, MA X-Newsreader: Gnus v5.7/Emacs 20.7 Xref: archiver1.google.com comp.lang.ada:28966 Date: 2002-09-14T02:33:44+00:00 List-Id: Peter Hermann writes: > Peter Amey wrote: > > grandparent-parent-unit_name.adb for subunits. > > In this context I have a question to language lawyers: > Since it may be practical to temporarily have package children > without having the corresponding parent, why should it be > prohibited by the standard to allow this? When you say "package A.B is..." you are referring to package A. The name A has to refer to some package declaration. Otherwise the whole model of visibility in Ada doesn't work (names denote declarations, sometimes implicit.) You might also write "with A;" temporarily before you have written package A. So you could ask the same question there -- why does the compiler complain when I say "with A;" and A does not exist. Therefore, I think what you're really asking for is that if A does not exist (in the compilation environment), then "package A.B is..." should mean that an empty package A is implicitly declared. That could work, but I don't think it's a good idea: You can easily write an empty package A if you like. So why should the compiler go to extra trouble to invent empty packages out of thin air? If Robert Dewar were listening, he would no doubt point out that readability is the key (not the minor pain of *writing* the empty package). He's right. If empty packages were imagined by the compiler, then when I see "package A.B is..." I have a problem. Suppose I can't find the source code for A. Perhaps I was looking in the wrong directory. Or perhaps A is implicitly empty. How do I (as the reader of the code) know which it is? Furthermore, if the compiler is supposed to imagine empty packages, how empty should they be? Should they contain "pragma Pure;" by default? Perhaps, but suppose I write "package A.B.C is..." and A exists, but B does not. A pragma Pure in B might be illegal (because maybe A is not Pure). > Likewise e.g. ada.text_io could turn to orphan > since package ada may easily be missing. I'm not sure what you mean by that. Package Ada is predefined in the RM, and provided by all implementations of Ada. How could it by "missing" unless you incorrectly installed your compiler? Perhaps you mean, package Ada could be implicitly empty in the RM (but then where does its pragma Pure come from?). I see no advantage in that kind of implicit declaration. (Suppose you were reading the RM, and you couldn't find the declaration of package Ada anywhere. Wouldn't that be confusing?) > While developing an application, I have e.g. a parent.child > but not yet a parent package, which may or may come later. > Now my compiler forces me to have the parent. > I would prefer the ada standard would force the compiler > to allow parentless children. > Did I ignore some important aspect? The Ada package hierarchy is analogous to directory hierarchies. It makes perfect sense to have a directory with no files in it, except nested subdirectories. But it makes no sense to have a subdirectory of A when A does not exist. Therefore, I think it is good that when you refer to A (via "with A;" or "package A.B is...") the compiler will complain if A does not exist. If you like, create an empty package A to make the compiler shut up. - Bob