comp.lang.ada
 help / color / mirror / Atom feed
From: ake.ragnar.dahlgren@gmail.com
Subject: Re: Accessibility checks
Date: Wed, 24 Jul 2013 06:01:21 -0700 (PDT)
Date: 2013-07-24T06:01:21-07:00	[thread overview]
Message-ID: <862c7bde-dfbe-44a4-8180-017c4e73f585@googlegroups.com> (raw)
In-Reply-To: <CE12B3D6.32F82%yaldnif.w@blueyonder.co.uk>

On Monday, July 22, 2013 11:03:02 AM UTC+2, Bill Findlay wrote:
> On 22/07/2013 07:11, in article 9a48d84b-4160-4824-a658-48dfcf12d0d6@googlegroups.com, "ake.ragnar.dahlgren@gmail.com" <ake.ragnar.dahlgren@gmail.com> wrote: > Den torsdagen den 18:e juli 2013 kl. 02:39:42 UTC+2 skrev Bill Findlay: >> On 18/07/2013 00:44, in article ks7a8v$4nj$1@loke.gir.dk, "Randy Brukardt" >> <randy@rrsoftware.com> wrote: > "Jeffrey Carter" >> <spam.jrcarter.not@spam.not.acm.org> wrote in message > >> news:ks718g$aim$2@dont-email.me... >> Brukardt, ARG member and editor of the >> ARM, claims that 'Access never >> works and 'Unchecked_Access is always >> required, bypassing the >> accessibility checks. While this is not entirely >> true, it's quite common >> that one must use 'Unchecked_Access, so we could >> do without these rules >> and checks in the majority of cases. > > That's not >> entirely true: I did find one (and only one) instance where I was > able to >> use 'Access in my code (it had to do with a library-level > initialization). >> Interesting. My projects have 37 occurrences of 'Access and only 2 of >> 'Unchecked_Access. -- Bill Findlay with blueyonder.co.uk; use surname & >> forename; > > Perhaps your projects use anonymous access types? No, I do not use any anonymous access types. -- Bill Findlay with blueyonder.co.uk; use surname & forename;

I do not use anonymous access types either.

A recipe for avoiding 'Unchecked_Access could be:
1) Instantiate as many objects at the library level as is suitable to be able to use 'Access.
2) The objects that are unnecessary to instantiate at startup (to avoid long startup time if the application is HUGE and use resources more wisely) are instantiated on the heap using smart pointers á la GNATColl.

The recipe is obviously not usable in projects where dynamic allocations are forbidden.

To deal with "the objects that are unnecessary to instantiate at startup" I can think of four scenarios:
1) Using anonymous access types.
2) Using Unchecked_Access
3) Dynamic allocation on the heap.
4) Dynamic allocation on the heap using smart pointers á la GNATColl.

Case 1) and 2) can lead to access types referencing non-existant objects. Case 3) can lead to memory leaks. Out of these case 4) seems to be safest since it protects against null pointer exceptions and memory leaks (although it won't protect from out of memory exceptions). Perhaps it is possible to verify using static code analysis that one has correctly used anonymous access types and Unchecked_Access in cases 1) and 2)? Maybe someone who has used CodePeer knows?

Anyways, I would like to extend my thanks to everyone who has participated in the "Accessibility checks" discussion. It gave me something to think about.

Best regards,
Åke Ragnar Dahlgren


  reply	other threads:[~2013-07-24 13:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-17 20:09 Accessibility checks Florian Weimer
2013-07-17 20:20 ` Alan Jump
2013-07-17 21:16 ` Jeffrey Carter
2013-07-17 23:44   ` Randy Brukardt
2013-07-18  0:39     ` Bill Findlay
2013-07-18  7:14       ` Simon Wright
2013-07-19  8:41         ` Georg Bauhaus
2013-07-19  4:48       ` Randy Brukardt
2013-07-22  6:11       ` ake.ragnar.dahlgren
2013-07-22  9:03         ` Bill Findlay
2013-07-24 13:01           ` ake.ragnar.dahlgren [this message]
2013-07-24 13:27             ` Dmitry A. Kazakov
2013-07-29  6:18               ` ake.ragnar.dahlgren
2013-07-18  0:41     ` Jeffrey Carter
2013-07-19  4:51       ` Randy Brukardt
replies disabled

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