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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,54889de51045a215 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-07 07:02:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.stueberl.de!newspeer1-gui.server.ntli.net!ntli.net!news-hub.cableinet.net!blueyonder!internal-news-hub.cableinet.net!news-text.cableinet.net.POSTED!53ab2750!not-for-mail User-Agent: Microsoft-Entourage/10.1.4.030702.0 Subject: Re: += in ada From: "(see below)" Newsgroups: comp.lang.ada Message-ID: References: <3F7316F7.219F@mail.ru> <17cd177c.0310010606.52da88f3@posting.google.com> <49cbf610.0310070205.2937e71a@posting.google.com> Mime-version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Date: Tue, 07 Oct 2003 14:02:08 GMT NNTP-Posting-Host: 82.41.184.118 X-Complaints-To: abuse@blueyonder.co.uk X-Trace: news-text.cableinet.net 1065535328 82.41.184.118 (Tue, 07 Oct 2003 15:02:08 BST) NNTP-Posting-Date: Tue, 07 Oct 2003 15:02:08 BST Organization: blueyonder (post doesn't reflect views of blueyonder) Xref: archiver1.google.com comp.lang.ada:378 Date: 2003-10-07T14:02:08+00:00 List-Id: On 7/10/03 12:56, in article slrnbo5afo.o7.lutz@taranis.iks-jena.de, "Lutz Donnerhacke" wrote: > declare > a : Typ renames X(b(i).all + 7); > begin > a := a + 2/a; > end; > > is legal Ada and a common idiom. Not always legal, see below. > Both ideas fail on considering a consitent semantic for volatile types and > exception handling. In both cases it's necessary to require a temporary copy > of the LHS. So nothing is gained from this proposal, beside a clear semantic > about access frequency for volatile data (one read and one write access). > > So I have to conlude, that the whole "idem" Idiom is useless at all. Some time ago, I posted this: > 1. It lets the programmer indicate that the occurrences of the LHS in the > RHS are *necessarily* the same, and not contingently so, which makes the > code more self-documenting. > 2. It removes a source of error in transcribing the LHS multiple times. > 3. It allows more concisely readable code when the LHS is lengthy. > 4. It provides functionality that it only partially available by means of > much clumsier renaming declarations, because not all objects can be renamed. > 5. It requires the compiler to evaluate the lvalue of the LHS once and reuse > that lvalue as often as needed to evaluate the RHS. This has three potential > benefits: shorter code, faster execution, and once-only invocation of any > side effects. > 6. It might make it somewhat easier for the compiler to generate > update-in-place object code, where the target architecture allows that and > where it offers a performance advantage. > 7. It provides all the utility of C's multitude of combined assignment > operators with one small, compatible change to the syntax of operands. > (I specify C, rather than C++, to avoid getting into a argument about > overloading assignment). > 8. It allows the expression of useful forms that C's combined assignment > operators cannot achieve (e.g. X := 1 - idem;). You regard all of these benefits as "useless"? -- Bill