comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: Not null feature with anonymous and named access types
Date: Thu, 15 Jun 2006 12:50:43 +0200
Date: 2006-06-15T12:50:43+02:00	[thread overview]
Message-ID: <4fcs9mF1irc04U1@individual.net> (raw)
In-Reply-To: 1150343308.372654.225640@f6g2000cwb.googlegroups.com

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




  parent reply	other threads:[~2006-06-15 10:50 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-12 20:33 Not null feature with anonymous and named access types Anh Vo
2006-06-12 21:26 ` Björn Persson
2006-06-12 23:13   ` Anh Vo
2006-06-13  7:53     ` Dmitry A. Kazakov
2006-06-13 15:27       ` Anh Vo
2006-06-14 15:13         ` Alex R. Mosteo
2006-06-14 15:37           ` Anh Vo
2006-06-14 17:00             ` Dmitry A. Kazakov
2006-06-15  3:48               ` Anh Vo
2006-06-15  8:21                 ` Dmitry A. Kazakov
2006-06-17  1:21                   ` Randy Brukardt
2006-06-17  8:24                     ` Dmitry A. Kazakov
2006-06-17 14:24                     ` Robert A Duff
2006-06-19 23:17                       ` Randy Brukardt
2006-06-15 10:50                 ` Alex R. Mosteo [this message]
2006-06-17  1:16 ` Randy Brukardt
2006-06-17 14:25   ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox