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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,10444cff97404845 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: C like op= proposal Date: 1999/08/18 Message-ID: <37BB1E9A.F3A5D609@mitre.org>#1/1 X-Deja-AN: 514363798 Content-Transfer-Encoding: 7bit References: <37B7D172.DCE02FFA@Maths.UniNe.CH> <87emh2l218.fsf@antinea.enst.fr> <7pd6th$2qj$1@nnrp1.deja.com> <7pefco$v7o$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.mitre.org X-Trace: top.mitre.org 935009719 7156 129.83.41.77 (18 Aug 1999 20:55:19 GMT) Organization: The MITRE Corporation Mime-Version: 1.0 NNTP-Posting-Date: 18 Aug 1999 20:55:19 GMT Newsgroups: comp.lang.ada Date: 1999-08-18T20:55:19+00:00 List-Id: Ted Dennison wrote: > If you are soliciting opinions, I think its beyond ugly. Agreed. There is a very subtle and painful problem with the Ada notation. A := A + 1; in Ada 83 could raise an exception. If it did A would have to remain unchanged in the exception handler, and if shared, if read by any other task. (A was never modified, so no intervening synchronization point was required.) This meant that the code could not use an increment instruction on many processor architectures. In Ada 95, 11.6(6) among other things allows increments to be used here. That was a very strong argument in Ada 83 for implementations and users to find a better way to get the += semantics. A lot of proposals were discussed, including both language "fixes" and implementation defined extensions. None of them ever caught on, because as people learned the language better they discovered that: In many cases where a fast increment was needed, the variable was a loop variable and the problem didn't arise. (Well once the compiler writers figured that the "right" Ada sequence to generate for the loop check is to check before the increment. Since the variable is never visible outside the loop, you don't need C or Fortran semantics.) In other cases, such as circular buffers, the user is the one who should do the check: "if Index = Buffer'Last then Index := Buffer'First else Index := Index + 1;" (Of course in Ada 95, you can do this with a modular type.) In many other cases where you wanted a fast increment the better way in Ada was to write at a higher level for example assigning slices instead of doing an element by element copy. So the need for any feature like this has almost completely gone away. (In C, I find I use one of these special forms at least every ten lines, mostly in loop declarations. In Ada, I am unlikely to "miss" one of them in several hundred lines, even if I am doing a direct translation from C. (Yes, I know, why translate from C? It is much easier on some code than putting in all the missing checks.) -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...