comp.lang.ada
 help / color / mirror / Atom feed
* Run-time accessibility checks (was: Construction initialization problem)
@ 2008-12-06 10:15 Dmitry A. Kazakov
  2008-12-06 17:10 ` Ludovic Brenta
  2008-12-11  0:55 ` Run-time accessibility checks (was: Construction initialization problem) Randy Brukardt
  0 siblings, 2 replies; 20+ messages in thread
From: Dmitry A. Kazakov @ 2008-12-06 10:15 UTC (permalink / raw)


On Fri, 5 Dec 2008 19:42:40 -0600, Randy Brukardt wrote:

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:d16z537mbee4$.wp9rmx0b7kjf.dlg@40tude.net...

>> The language problem is lack of abstraction. If there were abstract access
>> types, then you could make an instance of A implement the interface of
>> "access A" and them simply put an object of A as a discriminant for B:
>>
>>   type AA is new A and access A with null record; -- A and access to A
>>   overriding function "'Access" (X : A) return access A;
>>   function Create return AA; -- Creates an instance of AA
>>   B_with_A : B (Create); -- Constrain it by an object
> 
> I don't understand this point at all. But it doesn't matter, because a 
> function like your function "access" doesn't work: the accessibility will be 
> wrong.

Know what, nobody cares. The bad thing is that programmers used to use
Unchecked_Access everywhere. The idea of accessibility checks was good, but
its implementation in Ada was a flop.

It would be interesting to make a poll, how many programmers

1. start straight with Unchecked_Access

2. write Access first and then switch to Unchecked_Access after the first
compiler message without analyzing the message

3. try to understand the message and change the design

My guess is 65-30-5. Yours?

> I've been trying to work on this problem, but the obvious solutions would 
> require full dynamic accessibility checks, including passing the 
> accessibility of all by-reference parameters -- and that is way too 
> expensive to consider. Plus dynamic checks provide a new failure mechanism 
> for code; it's not clear that is an advantage.

Ooch, this is the major contributor to the group 1. If I had any danger
that X'Access might fail at run-time, I would immediately switch to
X'Unchecked_Access. It is absolutely unacceptable to me that a correct
program might fail at run-time because of accessibility checks. The only
case I could buy it, if exceptions where contracted, so that I would get an
compile-time error at some other place. Like "Constraint_Error may be
propagated, but the contract states otherwise."
 
> I think that I might be able to fix the problem in the context of the 
> containers only, and for dereference of the objects only, but it is not 
> clear that the fix is worth the effort.

It certainly does not. IMO Ada needs "setters" with the syntax sugar of an
assignment, it does not need outward access types. The whole idea is just
not Ada.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2008-12-17  8:54 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-06 10:15 Run-time accessibility checks (was: Construction initialization problem) Dmitry A. Kazakov
2008-12-06 17:10 ` Ludovic Brenta
2008-12-07  8:44   ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-07 14:56     ` Ludovic Brenta
2008-12-07 19:22       ` Dmitry A. Kazakov
2008-12-11  1:03     ` Randy Brukardt
2008-12-11  9:08       ` Dmitry A. Kazakov
2008-12-11  0:55 ` Run-time accessibility checks (was: Construction initialization problem) Randy Brukardt
2008-12-11  9:48   ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-11 11:21     ` Georg Bauhaus
2008-12-11 11:40       ` Dmitry A. Kazakov
2008-12-11 22:15   ` Run-time accessibility checks (was: Construction initialization problem) Randy Brukardt
2008-12-11 22:31     ` Randy Brukardt
2008-12-13  0:49       ` Randy Brukardt
2008-12-13  9:06         ` Run-time accessibility checks Dmitry A. Kazakov
2008-12-16  1:53           ` Randy Brukardt
2008-12-16  9:28             ` Dmitry A. Kazakov
2008-12-16 22:21               ` Randy Brukardt
2008-12-17  8:54                 ` Dmitry A. Kazakov
2008-12-12  9:21     ` Dmitry A. Kazakov

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