comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Reference counting and idempotent finalize
Date: Thu, 12 Sep 2013 09:33:15 +0200
Date: 2013-09-12T09:33:15+02:00	[thread overview]
Message-ID: <cmxjiszbw553$.14t1ai02acltb.dlg@40tude.net> (raw)
In-Reply-To: slrnl32kjd.1lme.lithiumcat@sigil.instinctive.eu

On Thu, 12 Sep 2013 05:34:53 +0000 (UTC), Natasha Kerensikova wrote:

> On 2013-09-11, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
>> You could make an alternative version for debug scenario which keeps track
>> of all changes of the reference count dumping them on errors. GNAT stack
>> trace is handy for that. Do not trust reference counting, it is an endless
>> source of many hideous errors even if the implementation of is correct.
> 
> Would you please elaborate on why reference counting shouldn't be
> trusted? What dangers am I brazingly exposing myself to?

Because reference counting scheme (and any GC in general) is based on
certain premises to work. These are always difficult to satisfy in a
real-life application. In particular, one that you have no circular
dependencies. The typical approach of breaking them (when you cannot
redesign it otherwise) is having weak references in addition to strong
ones. Consider a tree of nodes where parents refer to children and children
do to the parent. One reference is strong, a backward one must be weak.
That adds another layer of complexity to already messy thing.

The point is actually that problems come from the application domain. So,
time to time, you will have to inspect reference counts even if counting
implementation as such is all OK. Thus it is better to integrate some tools
for this right from the start.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


  reply	other threads:[~2013-09-12  7:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-11 10:45 Reference counting and idempotent finalize Natasha Kerensikova
2013-09-11 11:21 ` AdaMagica
2013-09-11 12:12 ` Dmitry A. Kazakov
2013-09-12  5:34   ` Natasha Kerensikova
2013-09-12  7:33     ` Dmitry A. Kazakov [this message]
2013-09-11 12:16 ` Dmitry A. Kazakov
2013-09-12  4:53   ` Natasha Kerensikova
2013-09-11 12:21 ` Jeffrey R. Carter
2013-09-11 20:03   ` Simon Wright
2013-09-12  4:46     ` Natasha Kerensikova
2013-09-12  5:05   ` Natasha Kerensikova
2013-09-12  7:54     ` Dmitry A. Kazakov
2013-09-12 17:03     ` Jeffrey R. Carter
2013-09-11 13:50 ` Pascal Obry
2013-09-12  4:56   ` Natasha Kerensikova
2013-09-12 14:33     ` Simon Wright
2013-09-12 15:40     ` Pascal Obry
2013-09-12 10:23 ` sbelmont700
2013-09-30  6:25 ` Natasha Kerensikova
2013-09-30 10:02   ` AdaMagica
2013-10-01  6:22     ` Natasha Kerensikova
replies disabled

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