comp.lang.ada
 help / color / mirror / Atom feed
From: Natasha Kerensikova <lithiumcat@gmail.com>
Subject: Re: Reference counting and idempotent finalize
Date: Thu, 12 Sep 2013 04:53:39 +0000 (UTC)
Date: 2013-09-12T04:53:39+00:00	[thread overview]
Message-ID: <slrnl32i63.1lme.lithiumcat@sigil.instinctive.eu> (raw)
In-Reply-To: 1c1whdbu9kbp9$.1vifz4b2nlphs.dlg@40tude.net

On 2013-09-11, Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> wrote:
> On Wed, 11 Sep 2013 10:45:37 +0000 (UTC), Natasha Kerensikova wrote:
>
>>    procedure Release (Access_Value : in out Access_To_Actual_Data) is
>>    begin
>>       if Access_Value /= null then
>>         Access_Value.all.Counter := Access_Value.all.Counter - 1;
>
> A minor stylistic issue, you don't need .all in order to access components:
>
>            Access_Value.Counter := Access_Value.Counter - 1;
>

I thought addressing it explicitly in the OP would spare me from the
remark.

Even though I don't need .all, and usually skip when not needed, there
are situations like this reference-counting code when I feel the
confusion between objects and accesses to objects is too easy and harms
readability (at least when the reader is me).

The null comparison on the previous line is not enough to recognize at a
glance that Access_Value is indeed an access value, so I knowingly wrote
the optional explicit dereferencing here.

Now I might be a bit biased by my C background, the implicit
dereferencing in Ada feels a lot like the implicit conversion from array
to pointer-to-the-first-element, and from function pointer to function.


  reply	other threads:[~2013-09-12  4:53 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 [this message]
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