comp.lang.ada
 help / color / mirror / Atom feed
From: adam@irvine.com (Adam Beneschan)
Subject: Re: Two ideas for the next Ada standard
Date: 1996/08/30
Date: 1996-08-30T00:00:00+00:00	[thread overview]
Message-ID: <507akg$t9u@krusty.irvine.com> (raw)
In-Reply-To: DwyFuC.E0K@world.std.com


bobduff@world.std.com (Robert A Duff) writes:

 >Independent of the question of child packages, it is definitely an
 >annoyance that a with_clause has to go up at the top, when you really
 >only want it for the private part.  The mistake, I think, is that the
 >syntax requires with_clauses outside the unit -- it makes more sense to
 >me, to put them inside:
 >
 >    package X is
 >        with Y;
 >        ...
 >    private
 >        with Z;
 >        ...
 >    end X;

To me, the mistake is that private parts have to be put in package
specs at all.  Ideally, if you declare a type "private" in the package
spec, you should be able to define the complete type in the package
body, which is the normal place to put things that you don't want
visible to other packages that use the package.  

The only reason it isn't in the body, as far as I can see, is that it
makes life more difficult for compilers, who would like to know how
big a type is before they compile other packages that use the spec.
This means that things like stack offsets and record component offsets
aren't known at compile time.  But it shouldn't be that difficult to
arrange things so that the linker can generate the correct offsets at
link time.  It may require a more sophisticated linker or more
sophisticated relocation information in the object file.  

I'm running into this problem right now.  I'm defining some new
private types, but I cannot define them in the private part, because
this would lead to recursive package dependencies.  (The types are in
package X, and package Y's spec WITH's package X, but I'd like to put
some data defined in Y in the definition of the private type.  Since I
can't do that without creating recursive dependencies, I've resorted
to the old trick of making the private type an access to a record
structure that's defined in X's body.  This works, but opens up a can
of worms related to memory allocation and garbage collection.

So my suggestion for the next Ada standard is to allow private types
to be completed in the package body, instead of requiring them to be
completed in the "private" part.  (If this would cause serious
difficulties for other language rules, or if there would be major
problems implementing this suggestion in some cases, I'm not aware of
the problem but would appreciate having someone point it out to me.)

(I know that someone [I don't remember who] made the same argument
around 1980 or 1981, pointing out that we'd all benefit from more
sophisticated linkers.  It's possible that the original Ada proposals
allowed you to complete private types in the package body, but that
this was changed at the request of implementors, leading someone to
argue against the change.  But my memory is hazy.)

                                -- Adam




  reply	other threads:[~1996-08-30  0:00 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-28  0:00 Two ideas for the next Ada standard Van Snyder
1996-08-29  0:00 ` Dale Stanbrough
1996-08-30  0:00   ` Robert A Duff
1996-08-30  0:00     ` Adam Beneschan [this message]
1996-08-31  0:00       ` Robert A Duff
1996-08-31  0:00         ` Robert Dewar
1996-09-04  0:00           ` Dennison
1996-09-05  0:00             ` Robert Dewar
1996-09-05  0:00               ` Dennison
1996-09-06  0:00                 ` Robert Dewar
1996-09-07  0:00                   ` Dennison
1996-09-07  0:00                     ` Robert Dewar
1996-09-06  0:00           ` Norman H. Cohen
1996-09-06  0:00             ` Robert A Duff
1996-09-06  0:00               ` Robert Dewar
1996-09-09  0:00               ` Norman H. Cohen
1996-09-06  0:00             ` Robert Dewar
1996-09-07  0:00             ` Keith Thompson
1996-09-12  0:00               ` Robert Dewar
1996-09-02  0:00         ` Geert Bosch
1996-09-02  0:00           ` Robert A Duff
1996-08-30  0:00 ` Peter Hermann
1996-08-30  0:00   ` Michael F Brenner
1996-08-30  0:00     ` Robert A Duff
1996-08-30  0:00       ` Robert Dewar
1996-08-31  0:00         ` Robert A Duff
1996-08-31  0:00           ` Robert Dewar
1996-09-01  0:00             ` Robert A Duff
1996-08-31  0:00   ` Robert Dewar
1996-09-01  0:00     ` Robert A Duff
1996-09-02  0:00 ` Laurent Guerby
1996-09-02  0:00   ` Robert Dewar
1996-09-03  0:00 ` Laurent Guerby
1996-09-03  0:00   ` Robert Dewar
1996-09-04  0:00     ` Adam Beneschan
1996-09-06  0:00       ` private parts (was: Two ideas for the next Ada standard) Arthur Evans Jr
1996-09-03  0:00 ` Two ideas for the next Ada standard Laurent Guerby
1996-09-03  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1996-08-31  0:00 Re:Two ideas for the next Ada Standard dulman
1996-09-01  0:00 ` Two " Robert Dewar
1996-09-01  0:00 ` Robert Dewar
1996-09-03  0:00   ` Jon S Anthony
1996-09-04  0:00     ` David Weller
1996-09-04  0:00     ` Joel VanLaven
1996-09-03  0:00   ` Larry Kilgallen
1996-09-03  0:00   ` Jonas Nygren
1996-09-03  0:00     ` Richard A. O'Keefe
1996-09-03  0:00       ` Jonas Nygren
1996-09-03  0:00         ` Robert A Duff
1996-09-04  0:00         ` Robert Dewar
1996-09-04  0:00         ` Richard A. O'Keefe
1996-09-03  0:00       ` Robert A Duff
1996-09-03  0:00         ` Dale Stanbrough
1996-09-04  0:00           ` Two " Richard A. O'Keefe
1996-09-03  0:00         ` Adam Beneschan
1996-09-04  0:00         ` Richard A. O'Keefe
1996-09-05  0:00           ` Robert A Duff
1996-09-06  0:00             ` Richard A. O'Keefe
1996-09-06  0:00               ` Robert Dewar
1996-09-10  0:00                 ` Richard A. O'Keefe
1996-09-10  0:00                   ` Robert Dewar
1996-09-10  0:00                   ` Mark A Biggar
1996-09-06  0:00               ` Robert A Duff
1996-09-05  0:00           ` Robert Dewar
1996-09-06  0:00             ` Richard A. O'Keefe
1996-09-04  0:00         ` Robert Dewar
1996-09-10  0:00       ` Robert I. Eachus
1996-09-03  0:00     ` Peter Hermann
1996-09-04  0:00       ` Robert Dewar
1996-09-04  0:00         ` Larry Kilgallen
1996-09-04  0:00     ` Robert Dewar
1996-09-04  0:00     ` Robert Dewar
1996-09-04  0:00   ` Jon S Anthony
1996-09-05  0:00     ` Mark A Biggar
1996-09-05  0:00     ` Robert A Duff
1996-09-04  0:00   ` Jonas Nygren
1996-09-06  0:00     ` Tucker Taft
1996-09-08  0:00     ` Jon S Anthony
1996-09-08  0:00       ` Robert Dewar
1996-09-09  0:00         ` John G. Volan
1996-09-09  0:00     ` Jon S Anthony
1996-09-04  0:00   ` Jon S Anthony
1996-09-04  0:00     ` Robert A Duff
1996-09-05  0:00   ` Robert I. Eachus
1996-09-06  0:00   ` Jon S Anthony
1996-09-07  0:00   ` Jonas Nygren
1996-09-08  0:00   ` Jon S Anthony
1996-09-08  0:00   ` Jon S Anthony
1996-09-08  0:00     ` Robert A Duff
1996-09-05  0:00 ` Jon S Anthony
1996-09-06  0:00 ` Jon S Anthony
1996-09-06  0:00 ` Jon S Anthony
1996-09-10  0:00 ` Norman H. Cohen
1996-09-10  0:00 ` Samuel Tardieu
1996-09-11  0:00 ` Jon S Anthony
1996-09-04  0:00 Bob Mathis
1996-09-04  0:00 Marin David Condic, 407.796.8997, M/S 731-93
1996-09-06  0:00 ` Jon S Anthony
1996-09-06  0:00 Marin David Condic, 407.796.8997, M/S 731-93
replies disabled

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