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!h11g2000prf.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Prohibiting dynamic allocation for the given type Date: Wed, 19 Mar 2008 07:38:37 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9ac94db1-01e1-4ce3-81d3-27f8b11f7662@h11g2000prf.googlegroups.com> References: <83335709-e099-416b-9967-5ab6aa0aea11@i12g2000prf.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1205937517 26047 127.0.0.1 (19 Mar 2008 14:38:37 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 19 Mar 2008 14:38:37 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: h11g2000prf.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:20488 Date: 2008-03-19T07:38:37-07:00 List-Id: 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