comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Ada2005 temp solo child (was: Re: The Dreaded "Missing Subunits"
Date: Sat, 14 Sep 2002 02:33:44 GMT
Date: 2002-09-14T02:33:44+00:00	[thread overview]
Message-ID: <wccfzwdqozb.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: als8ub$vf2$1@news.uni-stuttgart.de

Peter Hermann <ica2ph@iris16.csv.ica.uni-stuttgart.de> writes:

> Peter Amey <peter.amey@praxis-cs.co.uk> 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



  reply	other threads:[~2002-09-14  2:33 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-12 22:49 The Dreaded "Missing Subunits" Peter Richtmyer
2002-09-13  8:16 ` Peter Amey
2002-09-13  8:51   ` Ada2005 temp solo child (was: " Peter Hermann
2002-09-14  2:33     ` Robert A Duff [this message]
2002-09-13  9:24   ` Emmanuel Briot
2002-09-13 20:46     ` Simon Wright
2002-09-14  0:25     ` Chad R. Meiners
2002-09-14  2:53     ` Robert A Duff
2002-09-14 20:20       ` Simon Wright
2002-09-16 13:48         ` Ted Dennison
2002-09-16 16:33           ` Keith Thompson
2002-09-17  2:42             ` Ted Dennison
2002-09-18 20:56           ` Robert A Duff
2002-09-19  8:26             ` Emmanuel Briot
2002-09-19  9:55             ` Preben Randhol
2002-09-19 10:53             ` Marc A. Criley
2002-09-19 11:26             ` Marin David Condic
2002-09-19 21:49             ` Dmitry A.Kazakov
2002-09-19  9:47               ` Preben Randhol
2002-09-20  2:42                 ` Dmitry A.Kazakov
2002-09-19 15:33                   ` Stephen Leake
2002-09-19 15:36                   ` Preben Randhol
2002-09-20 22:31                     ` Dmitry A.Kazakov
2002-09-16 15:10       ` Emmanuel Briot
2002-09-18 21:17         ` Robert A Duff
2002-09-18 22:41           ` Stephen Leake
2002-09-19  0:00             ` Robert A Duff
2002-09-19  1:39               ` Keith Thompson
2002-09-19 15:19                 ` Stephen Leake
2002-09-19  4:02               ` Larry Kilgallen
2002-09-19 15:24               ` Stephen Leake
2002-09-19 20:34               ` Randy Brukardt
2002-09-19 14:44           ` Peter Richtmyer
2002-09-19 20:25           ` Randy Brukardt
2002-09-13 17:15 ` Mark Johnson
2002-09-13 20:56 ` Stephen Leake
2002-09-13 20:58 ` Simon Wright
2002-09-16 17:28   ` Peter Richtmyer
2002-09-19 20:05     ` Brian Gaffney
  -- strict thread matches above, loose matches on Subject: below --
2002-09-13  8:59 Ada2005 temp solo child (was: " Grein, Christoph
replies disabled

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