comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@world.std.com>
Subject: Re: "out" or "access"
Date: 1998/10/29
Date: 1998-10-29T00:00:00+00:00	[thread overview]
Message-ID: <wccn26ggo1i.fsf@world.std.com> (raw)
In-Reply-To: 70mo3h$gll$1@cf01.edf.fr

"Pascal Obry" <p.obry@der.edf.fr> writes:
> PS : The Win32Ada binding is full of access parameters that are just wrong !

That's because (1) the author didn't know about this rule (that access
parameters don't allow null), and (2) the compiler he was using didn't
check this rule (back then).

The access-parameter feature was invented specifically to solve the
following problem: You want to pass a tagged thing as a parameter to a
dispatching operation, and of course have it dispatch as usual, but you
want to store a pointer to that thing in a global data structure.
Therefore, access parameters have these features: (1) if the procedure
is in the right place, it's a dispatching op, (2) no null's are allowed,
because of course you can't dispatch unless you have a tag, and so the
pointer has to point to some tagged object, rather than be null, and (3)
you can pass pointers to more-nested things into less-nested procedures
(with some run-time accessibility checks).  You also get implicit
conversion of pointer-to-class-wide types (in the safe direction).

In retrospect, I think it would have been better to separate the
individual features more orthogonally.  Eg, I sometimes want to declare
a record component that can never be null -- Ada has a way to declare
never-null things, but only if they're formal parameters.

Another eg, if "type T2 is new T1...", then T2 implicitly converts to
T1'Class, but access-to-T2 does not implicitly convert to
access-to-T1'Class, except in the case of access parameters -- I would
like a more general feature, to avoid making "safe" conversions
explicit.

Given the specific problem access params were intended to solve, "access
constant" made little sense.  But in restrospect, I think we should have
allowed it.

It was only later that we noticed access params might be useful in
interface-to-C.  Of course that's only true for C functions that don't
expect a NULL.  It also requires the compiler to omit the extra dope
needed to do the run-time accessibility checks -- of course the C
compiler can't deal with that extra dope.

- Bob
-- 
Change robert to bob to get my real email address.  Sorry.




  reply	other threads:[~1998-10-29  0:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-10-21  0:00 "out" or "access" =:-) Vincent
1998-10-21  0:00 ` Jeff Carter
1998-10-21  0:00   ` Pat Rogers
1998-10-21  0:00     ` Martin C. Carlisle
1998-10-22  0:00       ` Pat Rogers
1998-10-22  0:00     ` Robert A Duff
1998-10-21  0:00 ` dennison
1998-10-21  0:00 ` Tucker Taft
1998-10-22  0:00   ` Pascal Obry
1998-10-29  0:00     ` Robert A Duff [this message]
1998-10-29  0:00       ` Matthew Heaney
1998-10-29  0:00         ` Robert A Duff
1998-10-30  0:00           ` dennison
1998-10-30  0:00             ` Matthew Heaney
1998-10-30  0:00               ` Robert A Duff
1998-10-31  0:00                 ` dewar
1998-10-31  0:00                   ` Matthew Heaney
1998-10-31  0:00                 ` Matthew Heaney
1998-11-01  0:00                   ` Robert A Duff
1998-11-01  0:00                     ` Matthew Heaney
1998-11-01  0:00                       ` Robert A Duff
1998-11-02  0:00                         ` Matthew Heaney
1998-11-03  0:00                           ` Simon Wright
1998-11-16  0:00                             ` Matthew Heaney
replies disabled

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