comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Preventing Unchecked_Deallocation?
Date: Wed, 8 Feb 2012 20:57:06 -0600
Date: 2012-02-08T20:57:06-06:00	[thread overview]
Message-ID: <jgvcm4$1o1$1@munin.nbi.dk> (raw)
In-Reply-To: ca07bff2-cb4f-4cd4-a191-249cb229840b@c20g2000vbb.googlegroups.com

"Maciej Sobczak" <see.my.homepage@gmail.com> wrote in message 
news:ca07bff2-cb4f-4cd4-a191-249cb229840b@c20g2000vbb.googlegroups.com...
> On 7 Lut, 07:26, Jeffrey Carter <spam.jrcarter....@spam.not.acm.org>
> wrote:
>
>> A basic design rule is: the reserved word access must not appear in the 
>> visible
>> part of a package specification.
>
> Don't worry. It will appear in the user package, where yours is
> withed.
> The smart user will define his own access types and will make pointers
> from your objects at the nearest opportunity and there's lots of them
> if the type in question is, for example, tagged.

There is absolutely no *requirement* to use access types with tagged types. 
Certainly a lot of uses will work just fine with statically allocated 
objects (for instance, Claw) or by putting them in instances of 
Ada.Containers.

And, as someone one else noted, if the client wants to declare a bunch of 
access types, that's just fine. Then it's their problem to keep track of the 
storage management needed; and they can't damage the library by doing an 
unexpected Unchecked_Deallocation (the library probably expecting objects to 
disappear at any time, and already handling such cases -- again, like Claw 
does). In addition, by letting the client use whatever storage management 
that makes the most sense (pools, subpools, containers, static allocation), 
the library has the most possible flexibility.

Over use of access types in OOP designs is a "feature" of other programming 
language designs (i.e. C++), but there is no need for Ada designers to make 
such mistakes.

My personal theory is the only reason for an Ada 95 program to use "access" 
in a specification is to get the effect of "in out" parameters for 
functions, and that's finally fixed for Ada 2012. I don't think there *ever* 
is a reason to dispatch directly on an access type -- in large part because 
it is a lie, what's really happening is that you're dispatching on 
"Ptr.all", and as such you should say that in the code (it's only 4 extra 
characters, but it makes a world of difference in understandability).

I recommend looking at the design of Claw to see how it can be done.

                                                Randy.





  parent reply	other threads:[~2012-02-09  2:57 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-02 23:41 Preventing Unchecked_Deallocation? Simon Belmont
2012-02-04 14:40 ` AdaMagica
2012-02-05 16:42   ` Simon Belmont
2012-02-06 12:52     ` Julian Leyh
2012-02-06 16:05       ` Adam Beneschan
2012-02-06 16:21     ` Adam Beneschan
2012-02-06 18:34       ` AdaMagica
2012-02-07  0:14       ` Simon Belmont
2012-02-07  2:19         ` Shark8
2012-02-07 16:39           ` Robert A Duff
2012-02-07 11:42         ` Gautier write-only
2012-02-07 21:11           ` Simon Belmont
2012-02-07 21:30             ` Robert A Duff
2012-02-07 22:23               ` Simon Wright
2012-02-07 23:07                 ` Robert A Duff
2012-02-08  8:43                   ` Simon Wright
2012-02-08 15:06                     ` Robert A Duff
2012-02-09  2:22                     ` Randy Brukardt
2012-02-09  7:28                       ` Simon Wright
2012-02-07 23:06               ` Alan Copeland
2012-02-07 23:10                 ` Robert A Duff
2012-02-09  2:49         ` Randy Brukardt
2012-02-09  3:39           ` Jeffrey Carter
2012-02-09 15:47             ` Adam Beneschan
2012-02-09 19:16               ` Jeffrey Carter
2012-02-09  7:37           ` Simon Wright
2012-02-10  1:08             ` Randy Brukardt
2012-02-10  7:35               ` Simon Wright
2012-02-07  6:26     ` Jeffrey Carter
2012-02-08  8:49       ` Maciej Sobczak
2012-02-08 23:40         ` BrianG
2012-02-09  2:57         ` Randy Brukardt [this message]
2012-02-09  7:13           ` Pascal Obry
2012-02-10  1:12             ` Randy Brukardt
2012-02-09  8:08           ` Maciej Sobczak
2012-02-10  1:18             ` Randy Brukardt
2012-02-07 16:27     ` Robert A Duff
replies disabled

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