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,591cbead201d7f34 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!8g2000hsu.googlegroups.com!not-for-mail From: gpriv@axonx.com Newsgroups: comp.lang.ada Subject: Re: Prohibiting dynamic allocation for the given type Date: Wed, 19 Mar 2008 08:43:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: <1bce3932-29e5-4d19-9068-dd1241e305bf@8g2000hsu.googlegroups.com> References: <83335709-e099-416b-9967-5ab6aa0aea11@i12g2000prf.googlegroups.com> <9ac94db1-01e1-4ce3-81d3-27f8b11f7662@h11g2000prf.googlegroups.com> NNTP-Posting-Host: 151.196.71.114 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1205941398 2420 127.0.0.1 (19 Mar 2008 15:43:18 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 19 Mar 2008 15:43:18 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 8g2000hsu.googlegroups.com; posting-host=151.196.71.114; posting-account=YaY8rAoAAAAAnFXOECY3BGVJsrvFJCgy User-Agent: G2/1.0 X-HTTP-Via: 1.1 SPARKS X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20489 Date: 2008-03-19T08:43:17-07:00 List-Id: On Mar 19, 10:38 am, Adam Beneschan wrote: > On Mar 18, 8:06 pm, gp...@axonx.com wrote: > > > > > On Mar 18, 5:30 pm, Maciej Sobczak wrote: > > > > Is it possible to "prohibit" dynamic allocation for the given type? > > > > Let's suppose that I have a type which instances make sense only on > > > the stack. > > > Ada is high level language and stack is implementation specific > > entity. ARM does not mention how the local objects are allocated (it > > simply irrelevant). In fact, GNAT uses two stacks for different type > > of objects but users don't have to know these details. > > > > I want to prohibit users from dynamically allocating > > > instances of this type so that they don't get into troubles. > > > Preferably at compile-time. > > > What's wrong with good old comments atop of type declaration. Like > > some beverages have: "for most enjoyment serve chilled" or "for best > > performance avoid heap allocation". > > > Don't know if it's ever possible to do it during compile, nothings > > comes to my mind. But if you insist you may do run-time check by > > defining custom Storage_Pool pool for your object and raising > > exception from Allocate method. See ARM 3.11 for details. > > No, you can only specify a Storage_Pool for an *access* type; you > can't specify that "all allocated instances of an object type will go > through such-and-such a Storage_Pool". > > -- Adam Agree. The only thing that I can see it useful is some sort of Lock object attached to the mutex (or like). Allocating this object dynamically, will mean that a user has no concept of what this object suppose to do therefore not knowing what he/she is doing. George.