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-7-bit Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!newsfeed.freenet.de!bolzen.all.de!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: Thu, 15 Jun 2006 12:50:43 +0200 Message-ID: <4fcs9mF1irc04U1@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> <4fana1F1i8fppU1@individual.net> <1150299433.315551.41490@g10g2000cwb.googlegroups.com> <18lx513zr1o49.lpffjwx41xi4.dlg@40tude.net> <1150343308.372654.225640@f6g2000cwb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: individual.net bJPACn2TYP4S39ieOjEpnAgR5vFGfdzaTDKfSX6u1FLep6x84= User-Agent: KNode/0.10.2 Xref: g2news2.google.com comp.lang.ada:4787 Date: 2006-06-15T12:50:43+02:00 List-Id: Anh Vo wrote: > Dmitry A. Kazakov wrote: >> On 14 Jun 2006 08:37:13 -0700, Anh Vo wrote: >> >> via *this* pointer, which does not mean that it cannot be reclaimed at >> all. Consider trivial stack allocated aliased variable. > > I am afraid I do not understand "this* pointer means. What I was > talking about not null access object using heap memory, not aliased > variable at all. See my code snipet from my original post. I think he's refering to something like (I certainly was): declare type AI is access all Integer; type NNAI is not null access all Integer; NNI : NNAI := new Integer'(6); I : AI := AI (NNI); begin -- You can't free NNI but you can free I. Of course, then NNI is -- dangling and can't be nullified, but it could get a new proper -- value. This would be fine if done in some body for whatever -- reasons. end; > >> No, you just don't use not-null pointers where deallocation is possible / >> necessary. That's the very idea of not-null pointers. > > I weight memory leak more important than convenient way of using null > excluded pointer. I am fine with not null pointer pointing to an > aliased object. In this case, attemptingp to deallocate the pointer is > clearly a language violation. > >> For example, consider an implementation of a container. Its public >> operation Get_Element could return a not-null pointer to the element, >> ensuring two things: 1. the client will never get a null (so no need to >> check it) 2. the client will never be able to deallocate the element >> through the pointer returned. Internally the implementation may allocate >> and deallocate elements using other pointers. So another operation >> Remove_Element_By_Index would do it. >> >> [It is still unsafe, as any aliasing is, yet definitely better than >> nullable pointers.] > > There is no disagreement here. > > AV