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.58.168 with SMTP id s8mr463265pbq.15.1316592476579; Wed, 21 Sep 2011 01:07:56 -0700 (PDT) Path: lh7ni1687pbb.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!feeder.news-service.com!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: discriminant questions Date: Wed, 21 Sep 2011 10:08:15 +0200 Organization: cbb software GmbH Message-ID: <1rffjj30r3vtr.1ahkfeok7ia0w.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> <1gti2q424e3tt$.18e95xse1r7j8$.dlg@40tude.net> <862244d4-c7ca-4590-ac97-e2988ac27872@f8g2000yqf.googlegroups.com> 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:18063 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2011-09-21T10:08:15+02:00 List-Id: On Tue, 20 Sep 2011 16:28:55 -0700 (PDT), ytomino wrote: > (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. If you want referential semantics that must be specified explicitly. I prefer to use containers of smart pointers for such purposes. Otherwise, I bet that a controlled accessor object would cost a lot more than copying for almost all elements. Controlled types are very expensive. Quite often copying (by-value semantics) is even desired when dealing with concurrency issues. It was one of key advantages of Ada 83 which tried to stay reference vs. value agnostic. It is sad to see, started with Ada 95, the drift towards IMO wrong direction under the influence of Java et al. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de