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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,70414f56d810c10c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.13.100 with SMTP id g4mr2761623pbc.25.1316520573267; Tue, 20 Sep 2011 05:09:33 -0700 (PDT) Path: lh7ni1099pbb.0!nntp.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!feedme.ziplink.net!news.swapon.de!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Tue, 20 Sep 2011 14:09:57 +0200 Organization: cbb software GmbH Message-ID: References: <9f37b726-d80b-4d24-bf3f-28a14255f7fd@s20g2000yql.googlegroups.com> <86015926-d652-4265-aedd-413312d399f9@dq7g2000vbb.googlegroups.com> <0d272f62-67d0-4905-972c-8a7e912c5531@en1g2000vbb.googlegroups.com> <148cxoyabima2.16mz6xwdph2hj.dlg@40tude.net> <1b7pl1piwc3hl.7q9fyyq8h3m7.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news1.google.com comp.lang.ada:18044 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-09-20T14:09:57+02:00 List-Id: On Tue, 20 Sep 2011 04:11:32 -0700 (PDT), AdaMagica wrote: > On 20 Sep., 09:38, "Dmitry A. Kazakov" > wrote: >> On Mon, 19 Sep 2011 19:01:05 -0500, Randy Brukardt wrote: >> >>>>> type Reference_Type (Element : access Integer) is null record; >> >>> The "good reason" for using this construct (beyond the obvious one of being >>> able to use the "implicit dereference" construct is one of lifetime. The >>> access discriminant of this object has the same lifetime as the enclosing >>> object; if that object is returned from a function, that is very short. >> >> That is why this cannot be used for smart pointers. For them the >> relationship is exactly opposite: Element always outlive the pointer except >> the last one. > > Excuse me, but that's nonsense. It is a very good reason to use this > construct. > See AdaCore Gem #107: > http://www.adacore.com/2011/06/06/gem-107-preventing-deallocation-for-reference-counted-types/ The example just confirms what I said: type Smart_Pointer is private; -- No discriminants! It uses access discriminant for the *accessor* kludge, which is an absolute different story (described by Randy): a short-living reference. P.S. I also see little or no point in using "accessors". Primitive operations Set and Get would be as good/bad. They are also cleaner, much more efficient and, what is far more important, they are *primitive*. Accossor is a new type which means *contravariance*. The stuff is not composable under inheritance. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de