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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e7d9fee9b42cd34e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Alex R. Mosteo" Newsgroups: comp.lang.ada Subject: Re: Not null feature with anonymous and named access types Date: Wed, 14 Jun 2006 17:13:17 +0200 Message-ID: <4fana1F1i8fppU1@individual.net> References: <1150144396.104055.164310@f6g2000cwb.googlegroups.com> <6_kjg.4603$E02.1474@newsb.telia.net> <1150154013.951160.154270@j55g2000cwa.googlegroups.com> <15d5p0cbyr817.1vzzowtu2dayj$.dlg@40tude.net> <1150212476.630345.297100@c74g2000cwc.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8Bit X-Trace: individual.net elrfUqOn3IfvxJGvMQb3NwknoczVwXw/8dE22/vzhKVZjWQZg= User-Agent: KNode/0.10.2 Xref: g2news2.google.com comp.lang.ada:4764 Date: 2006-06-14T17:13:17+02:00 List-Id: Anh Vo wrote: > > Dmitry A. Kazakov wrote: >> On 12 Jun 2006 16:13:34 -0700, Anh Vo wrote: >> >> > Bj�rn Persson wrote: >> >> Anh Vo wrote: >> >>> I have been exploring the not null feature with anonymous access type >> >>> and named access type. One thing have learned that an access variable >> >>> declared based on these types will raise a Constraint_Error when >> >>> deallocating this access variable as shown in the code below. >> >> >> >> Of course. Deallocation sets the access variable to null, and that >> >> violates the not-null constraint. >> >> >> > Thanks for your quick reply. >> > >> > Based on this requirement, one should not use not null access in this >> > case due to memory leak as the result of memory deallocation >> > incapability. >> >> Often memory management and handling objects should be well separated. In >> public interfaces, where pointers are needed, null access types can be >> very useful. This by no means should prevent the implementation >> interfaces from using plain pointers, arena allocators, garbage >> collectors, etc to manage memory. > > Agreed. However, memory leak occurs when the scope is complete in this > case. Therefore, not null access should be used with extreme care. > Otherwise, memory leak is almost certain. I don't see anything has radically changed in this respect since Ada95. You expose in the spec a not null type and in body use some nullable type for unchecked deallocations, if necessary.