comp.lang.ada
 help / color / mirror / Atom feed
From: "Alex R. Mosteo" <devnull@mailinator.com>
Subject: Re: Amount of copying on returned constant objects
Date: Tue, 19 Jun 2007 13:24:50 +0300
Date: 2007-06-19T13:24:50+03:00	[thread overview]
Message-ID: <5dpp8pF35116bU1@mid.individual.net> (raw)
In-Reply-To: f56pjg$nlr$1@jacob-sparre.dk

Randy Brukardt wrote:

> "Pascal Obry" <pascal@obry.net> wrote in message
> news:4676C27D.2050608@obry.net...
>> Or in a more Ada 2005 way:
>>
>>    function Element
>>      (Key : Key_Type) return access constant Element_Type;
> 
> The problem with this is that this access can be saved, and any operation
> on the original container could make it become dangling (and thus any
> further use be erroneous). That is *very* unsafe and virtually impossible
> to detect.

I see. I suspected that would be the reason for its absence. 

> There were a substantial number of people (a group that includes me) that
> want the containers to be safer than using raw access types (because they
> can do checks that would be too tedious to do in hand-written code).
> That's why the containers access-in-place routines use
> access-to-subprograms, because they can have tampering checks that prevent
> the dangling access problem (you get Program_Error if you try to do
> something that could make the element inaccessible). That makes them much
> safer than returning a raw pointer.

Actually I have benefitted from these sanity checks in real code. Too bad we
can have both things...

> We actually spent quite a bit of effort on trying to find a way to secure
> access values returned this way. But it isn't quite possible: even if you
> make them uncopyable; they still can be held onto long enough to
> potentially cause trouble with a renames.
> 
> What really would help would be a way for the container to know when the
> access was destroyed, but there isn't any obvious way to do that in Ada.

I guess then that some reference counting companion type (or maybe making
Cursors tagged and more heavyweight) was discarded because the distributed
overhead?



  parent reply	other threads:[~2007-06-19 10:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-15 16:19 Amount of copying on returned constant objects Alex R. Mosteo
2007-06-15 16:32 ` Ludovic Brenta
2007-06-18 17:26   ` Alex R. Mosteo
2007-06-19 10:22     ` Alex R. Mosteo
2007-06-15 22:03 ` Georg Bauhaus
2007-06-18 17:23   ` Alex R. Mosteo
2007-06-18 17:35     ` Pascal Obry
2007-06-18 18:04       ` Alex R. Mosteo
2007-06-18 20:25       ` Randy Brukardt
2007-06-19  8:26         ` Dmitry A. Kazakov
2007-06-19 10:24         ` Alex R. Mosteo [this message]
2007-06-19 21:33           ` Randy Brukardt
2007-06-20  1:31             ` Markus E Leypold
2007-06-20  6:25               ` Georg Bauhaus
2007-06-20 13:00                 ` Markus E Leypold
2007-06-20  7:34             ` Dmitry A. Kazakov
2007-06-18 18:34     ` Georg Bauhaus
2007-06-16  6:48 ` Dmitry A. Kazakov
2007-06-18 17:14   ` Alex R. Mosteo
replies disabled

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