From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5dacec64c8c879fa X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.135.231 with SMTP id pv7mr209506pbb.8.1328756229961; Wed, 08 Feb 2012 18:57:09 -0800 (PST) MIME-Version: 1.0 Path: wr5ni3378pbc.0!nntp.google.com!news1.google.com!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.x-privat.org!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Preventing Unchecked_Deallocation? Date: Wed, 8 Feb 2012 20:57:06 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <33a35da4-6c3e-4ab4-b58f-a9d73565d79a@t30g2000vbx.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1328756228 1793 69.95.181.76 (9 Feb 2012 02:57:08 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 9 Feb 2012 02:57:08 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-02-08T20:57:06-06:00 List-Id: "Maciej Sobczak" wrote in message news:ca07bff2-cb4f-4cd4-a191-249cb229840b@c20g2000vbb.googlegroups.com... > On 7 Lut, 07:26, Jeffrey Carter > 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.