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,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!o80g2000hse.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Containers - nontrivial element access Date: Tue, 02 Oct 2007 13:47:57 -0700 Organization: http://groups.google.com Message-ID: <1191358077.531499.198290@o80g2000hse.googlegroups.com> References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> <5mdfipFcv1dsU1@mid.individual.net> NNTP-Posting-Host: 85.3.68.29 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1191358077 31299 127.0.0.1 (2 Oct 2007 20:47:57 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 2 Oct 2007 20:47:57 +0000 (UTC) In-Reply-To: <5mdfipFcv1dsU1@mid.individual.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; 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: o80g2000hse.googlegroups.com; posting-host=85.3.68.29; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2253 Date: 2007-10-02T13:47:57-07:00 List-Id: On 2 Pa , 01:52, "Alex R. Mosteo" wrote: > I'm not sure the solution is clunky, unless you consider verbose=clunky. The point is that in order to swap data, you need to pass the new value to the modifying procedure. Since there are no on-the-fly binders, this value has to be provided by additional variable, which exists outside of the procedure, which access is passed. This looks like a dodgy hack: I provide a procedure, which is not self-contained anyway, so I also sneak around the value. I have nothing against the procedure, even if it is longer (/= clunky) than what I can do in C++. I have, however, a *serious* problem with sneaking this value around. This *is* clunky. > There are additional differences, if I'm not mistaken (my C++ is a bit > outdated). [] is, I think, unchecked (unlike .at()), so you could get a > violation with that code that shouldn't be possible in Ada. You are half right. The standard does not require [] to be checked. It does not forbid it, either. The point is not about [], actually, but about references. I might have written my example like this: swap(people.at(x).salary, people.at(y).salary); and then you would not have been able to nit-pick on the possible violation. :-) -- Maciej Sobczak * www.msobczak.com * www.inspirel.com