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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news1.google.com!eweka.nl!lightspeed.eweka.nl!newsfeeder.ewetel.de!news.germany.com!storethat.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Wed, 19 Mar 2008 23:17:46 +0100 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Prohibiting dynamic allocation for the given type References: <83335709-e099-416b-9967-5ab6aa0aea11@i12g2000prf.googlegroups.com> <89ac4348-4c21-478e-b491-97bfbebfdb86@p73g2000hsd.googlegroups.com> In-Reply-To: <89ac4348-4c21-478e-b491-97bfbebfdb86@p73g2000hsd.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <47e1910c$0$4754$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 19 Mar 2008 23:17:48 CET NNTP-Posting-Host: 9d852f71.newsspool3.arcor-online.net X-Trace: DXC=V6\?@f70ME0nBOkdL^Lo7>McF=Q^Z^V384Fo<]lROoR1^;5]aA^R6>2U``=O]ejV8SZl`c0XE>O?Nn[H]EKIE87 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:20495 Date: 2008-03-19T23:17:48+01:00 List-Id: Maciej Sobczak wrote: > On 19 Mar, 04:06, gp...@axonx.com wrote: > >> Ada is high level language > > That does not matter. > Ada is a high level language, but still provides two ways to create an > object: > > X : Type; > Y : Type_Ptr := new Type; > > If these two methods are available, then apparently there is a > difference between them and this difference is not in *where* objects > are created, but *how long* they are allowed to live. > > The high-level part of Ada can hide the "where" part, but not "how > long". (Somehow a posting of today is only visible through Google, but not via the news server, apologies if this a repeated remark.) Using Ada 2005, you can have some of the "how long" control. Deriving in nested scopes will limit the objects to that scope. This includes heap objects. For example, you cannot use pointers to Parent'Class to refer to objects of inner scope types. package body News10 is use Ada; procedure Scope is type T is new Finalization.Controlled with null record; type T_Ptr is access all T; overriding procedure Finalize(Object: in out T) is -- just show what is going on begin Text_IO.Put_Line("Finalized"); end Finalize; X: T_Ptr; begin Text_IO.Put_Line("Enter"); X := new T; pragma Inspection_Point(X); Text_IO.Put_Line("Exit"); end Scope; end News10; with News10; procedure Test_News10 is begin loop News10.Scope; delay 2.0; end loop; end;