comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Package Parts [was: Ada GC and a bunch of other stuff]
Date: 1996/02/23
Date: 1996-02-23T00:00:00+00:00	[thread overview]
Message-ID: <Dn8oJK.3Jn@world.std.com> (raw)
In-Reply-To: 4gglnj$9r8@dayuc.dayton.saic.com

I'll cc this to report@gnat.com, in case they're interested.

In article <4gglnj$9r8@dayuc.dayton.saic.com>,
John G. Volan  <John_Volan@ccmail.dayton.saic.com> wrote:
>It should be pointed out that the folks at ACT are planning to have GNAT
>provide something close to this capability, without changing the
>language. They're going to exploit the fact that the equation
>
>    1 Ada compilation unit = 1 operating system file
>
>is _NOT_ explicitly required by the language.

Actually, the equation that most Ada 83 compilers followed was
"1 Ada compilation = 1 operating system file".  Until GNAT came
along, everybody seemed to assume this.  Although it's not required
by the RM, the RM certainly implies that this was the intent, so it's
not surprising that everybody did it that way.  I'm glad the GNAT folks
have recognized that it's possible to be more flexible.  (Actually, GNAT
is *less* flexible, in that they disallow multiple compilation units per
file, but the case we're talking about here, of allowing the private
part to be split out, is *more* flexible.)

>(2) Unless the ACT folks intend to implement some fancy text-shuffling,
>a *.adp file will not be able to have its own context clause.  If they
>go with a naive implementation that merely concatenates the *.ads with
>the *.adp, then the top of the *.ads file will have to contain all the
>"with" clauses for the package spec, including those that are only
>needed for the private part (and that presumably would be different for
>each different version of the *.adp).

Yeah, this issue is a bit tricky.  It is clearly desirable for the
private part to have its own with_clauses.  (In fact, I consider
the lack of this feature to be a language design flaw.)

Now suppose GNAT allows that, and does some fancy text shuffling.
That is, they move the with_clauses up to the front.  Well, that's
certainly allowed by the RM (nobody says you have to store your
code in any particular form).  But it's undesirable, because it
means that the foo.ads file can refer to things that are not
mentioned in that file's with_clauses, but only in the corresponding
foo.adp file.

On the other hand, one might consider making the with_clauses in the
foo.adp file just apply to the private part.  That seems logical, but it
would be an incorrect implementation of Ada, because then if somebody
moved the with_clauses up, and concatenated the two files together, in
order to feed it to another compiler, it could become illegal.  (I don't
care about the fact that an illegal package could become legal, but it
should be impossible for a legal package to become illegal.)

A third possibility would be to say that the with_clauses are moved up
by the compiler, and the named packages can cause hiding and ambiguity,
but it is illegal to refer to them.  It's important that this be a
(post-overload resolution) Legality Rule.  This seems the most desirable
from the user's point of view, but it's no longer a trivial text
shuffle.  This rule would ensure that any pair of .ads/.adp files can be
text-shuffled and fed to another compiler, and it will still be legal.
It seems like a correct implementation, in the sense that GNAT would be
saying, "You may put some stuff in a .adp file, but if you do, you have
to obey an extra rule."  The extra rule would of course be wrong, if
it were not conditional in that way.

Another issue about this feature: The way it was originally described,
it sounded like the rule was: If the .ads file ends in "private",
without anything after it, then the compiler looks for a .adp file,
and concatenates that onto the end.  That seems undesirable.  Instead,
the rule should be: If a .adp file exists, then it is concatenated onto
the end.  In addition, if the .adp file exists, then the .ads file has
to end in "private".  This rule is better, because it avoids the problem
of silently ignoring the .adp file.

(GNAT has a similar bug, in that it silently ignores .adb files in the
case where the .ads file does not require a body.  ACT knows about that,
and I believe they intend to fix it.)

- Bob




  reply	other threads:[~1996-02-23  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <NEWTNews.824443067.649.geneo@medusa.ppp.rational.com>
1996-02-18  0:00 ` Package Parts [was: Ada GC and a bunch of other stuff] Ken & Virginia Garlington
1996-02-21  0:00   ` John G. Volan
1996-02-22  0:00   ` John G. Volan
1996-02-23  0:00     ` Robert A Duff [this message]
1996-02-22  0:00   ` John G. Volan
1996-02-23  0:00     ` Robert A Duff
1996-02-22  0:00 ` John G. Volan
1996-02-22  0:00   ` John G. Volan
1996-02-23  0:00   ` Robert A Duff
1996-02-23  0:00 ` Robert I. Eachus
replies disabled

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