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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,38fc011071df5a27 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-15 23:22:56 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!dialin-145-254-039-126.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Ideas for Ada 200X Date: Mon, 16 Jun 2003 08:25:39 +0200 Organization: At home Message-ID: References: <3EE7CC70.E1FD3A67@adaworks.com> <3EECA772.4B662024@adaworks.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-039-126.arcor-ip.net (145.254.39.126) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1055744574 19851743 145.254.39.126 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:39219 Date: 2003-06-16T08:25:39+02:00 List-Id: Richard Riehle wrote: > Steve wrote: > >> In my opinion the benefit of += has nothing to do with efficiency or ease >> in >> writing. It's all about readability. > > If we adopt this syntax, in Ada, we will need to include some rules in the > language to enable the compiler to discern a clear difference between > the += and :=. That is, in Ada's current model, we want to compiler to > be able to tell us when a construct is a mistake or warn us when it will > potentially create an incorrect execution. > > What rule can you come up with that will enable the compiler to, at > minimum, warn the programmer that this, > > i := 1; > i += 1; > > poses no hazard. It is bad enough that, in many derivates from C, a > legal but > > erroneous code can be created when the programmer confuses the = and the = > =. This cannot currently happen in Ada, ever. > > So, if there is some approach that will ensure that my i += 1 could not be > a mistake > for i := 1, that would go a long way toward making it an acceptable > construct. It could be quite easy in Ada: i + 1; -- Here "+" is a *procedure* (:-)) procedure "+" (Left : in out Integer; Right : Integer); > Granted, in C the = symbol is an assignment. Therefore, the = = will > not be mistaken > for a +=. However, the use of these shortcuts can have interesting > results when used > incorrectly. Consider the difference between ++i and i++. Often this > will not create > a problem. Often it will. Yes, the real pain is to ensure a compatible semantic of all that mess. It is often very difficult in C++, which has a plethora of quasi-arithmetic operators, plus explicit by-value vs. by-reference semantics, plus various forms of construction / initialization, plus distiguishable constant vs. non-constant variations. Now imagine a type which has all this stuff, and you have to derive from it overriding [which operations?]. Well, then good luck! Should Ada some time have things like "++", "+:=" etc, the compiler shall at least imlicitly generate non-overridden operations them from user-defined ones, as it does for "/=". -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de