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,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!news.glorb.com!news2.euro.net!newsfeed.freenet.de!news.osn.de!diablo1.news.osn.de!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Containers - nontrivial element access Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> <1191358254.405682.320670@22g2000hsm.googlegroups.com> <4hBMi.132431$Fc.72735@attbi_s21> <10xbnt0vkcyeo.5t72qwg3umwd.dlg@40tude.net> Date: Wed, 3 Oct 2007 21:35:57 +0200 Message-ID: <1xme76ugfqkxc$.4f6zomz823re$.dlg@40tude.net> NNTP-Posting-Date: 03 Oct 2007 21:36:00 CEST NNTP-Posting-Host: 93bb8a3a.newsspool4.arcor-online.net X-Trace: DXC=]@MjI2WNT0>lIh70@DNcfSJ;bb[5IRnRBaCdl\DflPH:Yn1fO\VZeVTY^7 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:2271 Date: 2007-10-03T21:36:00+02:00 List-Id: On Wed, 03 Oct 2007 18:49:58 GMT, Jeffrey R. Carter wrote: > Dmitry A. Kazakov wrote: >> >> This is IMO utterly wrong. The semantics of swapping element's fields is >> well-defined independently on the way of access. In question in not the >> semantics of, but the syntax sugar, namely an array-like indexing of the >> container. > > Swapping was only an example. Essentially, the OP was looking for the > ability to do > > People.Element (X).Salary := S; > > and have it modify the value in the data structure. Which is no problem if Element is an array field of records having the field Salary. Ada does not prescribe whether that would be by reference. AFAIK, the compiler is allowed to rewrite the whole People if it wanted to. The compiler is free to choose between the decompositions: ":=" (People.Element (X).Salary, 3) ":=" (People.Element (X), ".Salary", 3) ":=" (People, "Element", X, "Salary", 3) This freedom is not offered to the developer of a component library. > C++ uses reference semantics, so that a modification of a field modifies > the value in the data structure. Ada uses value semantics, so that > modification of a field does not modify the value in the data structure. ? For by-value things Ada compiler just does copy-out / copy-in, transparently. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de