comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@world.std.com (Robert A Duff)
Subject: Re: Two ideas for the next Ada Standard
Date: 1996/09/03
Date: 1996-09-03T00:00:00+00:00	[thread overview]
Message-ID: <Dx5ywt.Jvn@world.std.com> (raw)
In-Reply-To: 322C40B1.534A@ehs.ericsson.se


In article <322C40B1.534A@ehs.ericsson.se>,
Jonas Nygren  <ehsjony@ehs.ericsson.se> wrote:
>type X1A is access X;
>type X2A is access X;
>X1P : X1A;
>X2P : X2A;
>
>To use X1P and X2P together often requires conversions.

So don't do that.  ;-)  Just define one access type after each type, and
use a naming convention, and always use that particular type.

You *do* get "extra" type conversions, though, when using class-wide
types -- if T2 is derived from T1, then T1'Class covers T2'Class, but
the corresponding thing doesn't work for access-to-those-classwide-types.

>If you write code using tagged types you often want to use dynamically
>allocated objects and hence use access values in function/procedure
>calls. When one pass 'the object' as an access argument the 'object'
>will always have mode 'in out', it is not possible to pass the
>object with only 'in' mode. So if you want to provide functions
>or procedures which restricts the update of 'the object' then
>you have to provide an interface with a mix of 'access' and
>'in' modes with the following confusion for the user of the interaface
>who will need to use a mix of P1(XA) and P2(XA.all). It is very ugly
>and confusing to use such interfaces.

I suppose that's a valid criticism.  The reason there are no "access
constant" parameters is that we didn't think it was needed, which is not
usually a good language design principle -- the language should forbid
harmful things, but shouldn't forbid percieved-useless things,
especially since it's not always clear what will be useful to somebody.
I guess it depends on whether you think "access constant" params is an
additional feature, versus the lack of "access constant" params being an
additional restriction.

However, I don't think it's a big deal.  You can just use "in" and "in
out" all the time, and use ".all" at the call site.  Two annoying things
are: The syntax for ".all" is ugly -- I liked Pascal's "^".  And
functions can't have "in out" params.

You only need access parameters when the dispatching function wants to
store a pointer to the thing in some global data structure, which I
think is no common.  And when you have a function with side-effects,
which is also rare.  (Note that parameters of a tagged type are always
aliased, so you can do 'Access or 'Unchecked_Access, but the
accessibility rules make access parameters more friendly.)

And in any case, missing or extra ".all"'s and 'Accesses are caught at
compile time.

- Bob




  reply	other threads:[~1996-09-03  0:00 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-31  0:00 Re:Two ideas for the next Ada Standard dulman
1996-09-01  0:00 ` Two " Robert Dewar
1996-09-03  0:00   ` Jonas Nygren
1996-09-03  0:00     ` Peter Hermann
1996-09-04  0:00       ` Robert Dewar
1996-09-04  0:00         ` Larry Kilgallen
1996-09-03  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 Dewar
1996-09-06  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-04  0:00         ` Robert Dewar
1996-09-03  0:00       ` Jonas Nygren
1996-09-03  0:00         ` Robert A Duff [this message]
1996-09-04  0:00         ` Robert Dewar
1996-09-04  0:00         ` Richard A. O'Keefe
1996-09-10  0:00       ` Robert I. Eachus
1996-09-04  0:00     ` Robert Dewar
1996-09-04  0:00     ` Robert Dewar
1996-09-03  0:00   ` Larry Kilgallen
1996-09-03  0:00   ` Jon S Anthony
1996-09-04  0:00     ` David Weller
1996-09-04  0:00     ` Joel VanLaven
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-04  0:00   ` Jon S Anthony
1996-09-05  0:00     ` Mark A Biggar
1996-09-05  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     ` Robert A Duff
1996-09-08  0:00   ` Jon S Anthony
1996-09-01  0:00 ` Robert Dewar
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
  -- strict thread matches above, loose matches on Subject: below --
1996-09-06  0:00 Marin David Condic, 407.796.8997, M/S 731-93
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-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
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 Dewar
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-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-03  0:00 ` Laurent Guerby
1996-09-03  0:00   ` Robert Dewar
replies disabled

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