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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!r29g2000hsg.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: Containers - nontrivial element access Date: Wed, 03 Oct 2007 12:09:30 -0700 Organization: http://groups.google.com Message-ID: <1191438570.552084.264990@r29g2000hsg.googlegroups.com> References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> <1191358254.405682.320670@22g2000hsm.googlegroups.com> <4hBMi.132431$Fc.72735@attbi_s21> <10xbnt0vkcyeo.5t72qwg3umwd.dlg@40tude.net> NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1191438570 27867 127.0.0.1 (3 Oct 2007 19:09:30 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 3 Oct 2007 19:09:30 +0000 (UTC) In-Reply-To: User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: r29g2000hsg.googlegroups.com; posting-host=66.162.65.129; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2268 Date: 2007-10-03T12:09:30-07:00 List-Id: On Oct 3, 2:49 pm, "Jeffrey R. Carter" wrote: > > People.Element (X).Salary := S; > > and have it modify the value in the data structure. > > C++ uses reference semantics, No, C++ has explicit reference types. Ada of course has "reference semantics" too, for composite types (at the discretion of the implementation), for tagged types, and for limited types that are "inherently" limited. The C++ STL declares the index operator to return a reference to the element: value_type& operator[](size_type); const value_type& operator[](size_type) const; Of course, the C++ has by-value passing too. The C++ STL uses by- value passing for some of its operations, e.g. iterator operator++(int); //post-fix form of inc operator In fact, any arithmetic operator would have to return its result by- value. > so that a modification of a field modifies > the value in the data structure. Ada uses value semantics, Ada has both value semantics and reference semantics. The language specifies value semantics for some parameter classes (scalar or access values) and reference semantics for others (tagged, limited, etc). > so that > modification of a field does not modify the value in the data structure. But reference passing mechanism is completely orthogonal to the issue being able to modify --in situ-- the container element.