From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!weretis.net!feeder1.news.weretis.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: Reference counting and idempotent finalize Date: Thu, 12 Sep 2013 04:53:39 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: <1c1whdbu9kbp9$.1vifz4b2nlphs.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Thu, 12 Sep 2013 04:53:39 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="31d6bde745a337034b005384ef225743"; logging-data="25524"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+z4OLRVoFk+oBZ6qUQXUoG" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:s0Up4Vcz6JZaMZC2EV6oAxtW67w= X-Original-Bytes: 2355 Xref: number.nntp.dca.giganews.com comp.lang.ada:183340 Date: 2013-09-12T04:53:39+00:00 List-Id: On 2013-09-11, Dmitry A. Kazakov 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.