comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Problem in "X (1).Re := X (1).Re + 1"
Date: Wed, 9 May 2012 19:58:04 -0500
Date: 2012-05-09T19:58:04-05:00	[thread overview]
Message-ID: <jof3r1$475$1@munin.nbi.dk> (raw)
In-Reply-To: 30097103.0.1336555778034.JavaMail.geo-discussion-forums@pbcow8

"ytomino" <aghia05@gmail.com> wrote in message 
news:30097103.0.1336555778034.JavaMail.geo-discussion-forums@pbcow8...
...
> I had not made an issue of deallocation, too.
> At first, I wanted to make calling Reference earlier than calling 
> Constant_Reference in same statement.
> But it's a kind of "dangling pointer".
> Real problem is old access value designated to the shared area still alive 
> after copy-on-write.
> (I'm so thankful to Adam.)

This reminds me of something I forgot: The beauty of 
Constant_Reference/Reference in the standard containers is that there cannot 
be a dangling pointer (assuming no Unchecked programming is involved). These 
are tampering events so long as the pointer still exists, and thus is it 
impossible to modify the container (attempts to do so will raise 
Program_Error).

So the act of assigning a "Constant_Reference" as Adam did is to "lock" the 
container from [most] modification for a long time. That might be a problem 
for the program, but it can't cause the container to become corrupt.

(Iterators also use the tampering solution to prevent problems, but they use 
a weaker form.)

Of course, that might not be true for a user-defined container, but then you 
have to work out your own solution to the problem.

                              Randy.





  reply	other threads:[~2012-05-10  0:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-05 12:55 Problem in "X (1).Re := X (1).Re + 1" ytomino
2012-05-07 15:37 ` Adam Beneschan
2012-05-07 18:53   ` ytomino
2012-05-07 21:28     ` Adam Beneschan
2012-05-08  1:14       ` Randy Brukardt
2012-05-08 17:14         ` Adam Beneschan
2012-05-08 22:29           ` Randy Brukardt
2012-05-09  8:41             ` ytomino
2012-05-10  0:52               ` Randy Brukardt
2012-05-10  5:23                 ` ytomino
2012-05-09  9:29           ` ytomino
2012-05-10  0:58             ` Randy Brukardt [this message]
2012-05-10  4:26               ` ytomino
2012-05-15  6:09                 ` Randy Brukardt
2012-05-15 20:17                   ` ytomino
2012-05-16  0:01                     ` Randy Brukardt
2012-05-15 22:12               ` Simon Wright
2012-05-16  7:14                 ` Dmitry A. Kazakov
2012-05-09  8:05       ` ytomino
2012-05-09 11:03         ` ytomino
replies disabled

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