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: a07f3367d7,70414f56d810c10c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Tue, 20 Sep 2011 14:57:23 +0200 Organization: cbb software GmbH Message-ID: <1gti2q424e3tt$.18e95xse1r7j8$.dlg@40tude.net> 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> <3d49749a-1da5-49b9-bc68-5d9befb4ed62@hb5g2000vbb.googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Xref: g2news1.google.com comp.lang.ada:21019 Date: 2011-09-20T14:57:23+02:00 List-Id: On Tue, 20 Sep 2011 05:31:34 -0700 (PDT), AdaMagica wrote: >> P.S. I also see little or no point in using "accessors". Primitive >> operations Set and Get would be as good/bad. > > No, here it's you who misunderstands. Get is still present and returns > an accessor instead of an access type and thus makes accesses safe (no > way to deallocate the accessed object). And Get *is* primitive. Get that returns an independent type breaks inheritance. Without accessor you have two hierarchies Object : T <-- S <-- Q Handles : T_Handle <-- S_Handle <-- Q_Handle with accessors you add here a third one: Accessors : Ref_T <-- Ref_S <-- Ref_Q Now, because Ada does not support MD in any usable form, the above would quickly turn into an utter mess. Get a primitive operation of T_Handle is contravariant in its result, it will always return Ref_T or at best Ref_T'Class. It cannot return Ref_S. > And with reference types and objects in Ada 2012, there is no more > need for explicit dereference: What is wrong with Get returning the target: P.Get? The accessor-kludge does not eliminate anything, it does dereference the reference it has first introduced! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de