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,d2f0af5e440b367f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-06-25 03:25:39 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fu-berlin.de!uni-berlin.de!dialin-145-254-043-044.arcor-ip.NET!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: proposal for new assignment operators Date: Wed, 25 Jun 2003 12:28:22 +0200 Organization: At home Message-ID: References: Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: dialin-145-254-043-044.arcor-ip.net (145.254.43.44) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: fu-berlin.de 1056536738 28787176 145.254.43.44 (16 [77047]) User-Agent: KNode/0.7.1 Xref: archiver1.google.com comp.lang.ada:39712 Date: 2003-06-25T12:28:22+02:00 List-Id: Russ wrote: > As most of you are aware, several very popular programming languages, > such as C, C++, Java, Perl, and Python, have what are called > "assignment operators." The most important of these operators are > "+=", "-=", "*=", and "/=". > > On a recent thread, the usefulness of those operators was discussed in > detail, so I won't rehash it. > > One of the problems with adding these operators to Ada is that "/=" is > already used for "not equals." So I suggested that the Ada version of > these operators could be ":+", ":-", ":*", and ":/". I did not get > much of a reply, but I think it's an idea worth considering, so I am > repeating it here. > > These operators would be consistent with the ":=" assignment operator > of Ada, and I don't think they conflict with any established Ada > operator. I actually think they make *more* sense than the usual "+=" > type operators. Consider, for example, > > count :+ 1 > EulerAngles :* D2R > > I'm wearing my asbestos underwear, so have at it! The real problem is not to find a better sequence of characters. The real problems are: 1. Ada does not have any assignment operator. It has an assignment statement. Carefully observe all the consequences of that. When I and others proposed to allow operators be implemented by procedures, the goal was to approach this problem. 2. Ada isn't C++. One have to provide an easy and safe way to ensure that "+" and in-place-"+" have compatible semantics. The language default has to be safe. This is why I made another proposal to invent a mechanism instructing the compiler to deduce one operations from others. Such things exist presently for "/=" which is automatically deduced from "=". And for ":=", which is automatically deduced from Finalize, Adjust and assignments of the components. IMO we need something like: procedure ":+" (L : in out Matrix; R : Matrix); function "+" (L, R : Matrix) return Matrix; for "+" use ":+"; But it is not an easy issue. Consider tagged types. You have overridden ":+", but not "+". What have the language to say in such cases? Again, Ada need not to become Ada += C++; One C++ is already too much for our planet. ------- Provided 1.& 2. one could just enlarge the set of lexical elements and let the programmer to choose what he/she wants. I would like to see "<+>", "[+]", "(+)", "+:=", "<+>:=" etc added, but is that worth the efforts? -- Regards, Dmitry A. Kazakov www.dmitry-kazakov.de