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,e7d9fee9b42cd34e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Not null feature with anonymous and named access types Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH 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> Date: Wed, 14 Jun 2006 19:00:16 +0200 Message-ID: <18lx513zr1o49.lpffjwx41xi4.dlg@40tude.net> NNTP-Posting-Date: 14 Jun 2006 19:00:05 MEST NNTP-Posting-Host: 6ce5d54c.newsread2.arcor-online.net X-Trace: DXC=ZVi`N>ZMm0B4mA>;52^R7KQ5U85hF6f;DjW\KbG]kaMHVA=iV<7g:2Eb`VX^>hkIUJWRXZ37ga[7JjTA67ckJ=XE:Y:QXZK4_;O X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:4768 Date: 2006-06-14T19:00:05+02:00 List-Id: On 14 Jun 2006 08:37:13 -0700, Anh Vo wrote: > Alex R. Mosteo wrote: >>> 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. > > It is nice to have null excluded feature. However, memory can not be > reclaimed, via *this* pointer, which does not mean that it cannot be reclaimed at all. Consider trivial stack allocated aliased variable. > in this case, because of Constraint_Error raised when > attempting to deallocate it. In Ada 95, null excluded not available, > Constraint_Error will not be raised when deallocate the access object > again in this case. No, you just don't use not-null pointers where deallocation is possible / necessary. That's the very idea of not-null pointers. 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.] -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de