comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Reference counting and idempotent finalize
Date: Mon, 30 Sep 2013 06:25:15 +0000 (UTC)
Date: 2013-09-30T06:25:15+00:00	[thread overview]
Message-ID: <slrnl4i69v.1lme.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: slrnl30ie3.1lme.lithiumcat@sigil.instinctive.eu

Hello,

On 2013-09-11, Natasha Kerensikova <lithiumcat@gmail.com> wrote:
> I have recently reinvented the reference counted wheel, and been told
> that I got it all wrong because Finalize must be idempotent. However I
> already diffusely knew that, though I cannot remember from where it
> comes or whether I thought of it as a hard requirement or only as a good
> practice (the difference is hard to tell when such a rule is
> internalized).
>
> Anyway, my naive implementation looks like that:
>
>    [...]

So I have published the implementation on github (and on a public fossil
repository on my server, but that's nearly as trendy), it's available
at :
https://github.com/faelys/natools/blob/trunk/src/natools-references.ads

One feature it has that I haven't found it most other implementations
mentioned here or found through a web search, is that it places no
requirement on the referenced type.

In particular, it allows creating reference to any existing type without
having to change it, e.g. Ada.Text_IO.File_Type.

The fact that it supports referencing to a limited type is a large part
of my needs. I remember someone here (I think it was Randy) saying that
limited types are a pain and should be avoided in public interfaces, in
favor of a reference-semantic non-limited type. So I declare the
intrinsically limited type in the private part of the specification and
use the reference counter to provide the semantics of the public type.
That's why I haven't found the need yet for weak references or
concurrency.

Any comment about my code is welcome, should anyone take the time to
have a look at it.


Thanks for your help,
Natasha


  parent reply	other threads:[~2013-09-30  6:25 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
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 [this message]
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