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 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.11.4 with SMTP id m4mr165338pbb.31.1316561335610; Tue, 20 Sep 2011 16:28:55 -0700 (PDT) Path: lh7ni1427pbb.0!nntp.google.com!news1.google.com!postnews.google.com!f8g2000yqf.googlegroups.com!not-for-mail From: ytomino Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Tue, 20 Sep 2011 16:28:55 -0700 (PDT) Organization: http://groups.google.com Message-ID: <862244d4-c7ca-4590-ac97-e2988ac27872@f8g2000yqf.googlegroups.com> 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> <1gti2q424e3tt$.18e95xse1r7j8$.dlg@40tude.net> NNTP-Posting-Host: 118.8.62.179 Mime-Version: 1.0 X-Trace: posting.google.com 1316561335 25076 127.0.0.1 (20 Sep 2011 23:28:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 20 Sep 2011 23:28:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f8g2000yqf.googlegroups.com; posting-host=118.8.62.179; posting-account=Mi71UQoAAACnFhXo1NVxPlurinchtkIj User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HNKUARELSC X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_5_8) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1,gzip(gfe) Xref: news1.google.com comp.lang.ada:18058 Content-Type: text/plain; charset=ISO-8859-1 Date: 2011-09-20T16:28:55-07:00 List-Id: (To avoid confusion, I do not use names of "Get" and "Set".) function Element (C : Container) return Element_Type; function Set_Element (C : Container; New_Item : Element_Type); These functions may copy Element_Type. It's futile cost if Element_Type'Size is large. function Element (C : Container) return access constant Element_Type; It's dangerous. the reason is written in AdaCore Gem #107. procedure Query_Element (C : Container; Process : access procedure (Item : in Element_Type)); procedure Update_Element (C : Container; Process : access procedure (Item : in out Element_Type)); These procedures are better than above functions. No copy, no dangerous. But, we must make nested subprogram, so source code may be verbosity. function Constant__Reference (C : Container) return Constant_Reference_Type; function Reference (C : Container) return Reference_Type; These functions give same effects as Query_Element and Update_Element. And These are simple to use. In fact, Element, Set_Element, Query_Element and Update_Element are able to be implemented with Reference. The reverse is impossible. Therefore I think Constant__Reference and Reference are more better functions ... aside from primitive or not. I also understand your feeling because the mechanism of accessor is complex a little to call primitive. But accessor is a nice idea, not kludge.