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,FREEMAIL_FROM autolearn=ham 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 12:17:43 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: proposal for new assignment operators Date: 25 Jun 2003 12:17:42 -0700 Organization: http://groups.google.com/ Message-ID: References: NNTP-Posting-Host: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1056568663 10670 127.0.0.1 (25 Jun 2003 19:17:43 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 25 Jun 2003 19:17:43 GMT Xref: archiver1.google.com comp.lang.ada:39736 Date: 2003-06-25T19:17:43+00:00 List-Id: "Dmitry A. Kazakov" wrote in message news:... > Russ wrote: > > count :+ 1 > > EulerAngles :* D2R > The real problem is not to find a better sequence of characters. The real > problems are: Agreeing on a sequence of characters is not a *technical* problem, but it is a problem nevertheless, and it could actually turn out to be very difficult > 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. As someone pointed out on an earlier thread, "+=", ":+", or whatever you call it, is just "semantic sugar" for a procedure like "Add_Matrix". It really has nothing to do with assignment per se. So I fail to see the relevance of the fact that Ada has no assignment operator. > 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: I agree it would be nice to have language enforcement of consistency between operators, but I think that would be going beyond what Ada already allows. Does Ada require a user-defined "+" operator to be consistent with the corresponding "-" operator? No. "+" could add matrices, and "-" could send email to Santa Claus. > procedure ":+" (L : in out Matrix; R : Matrix); > function "+" (L, R : Matrix) return Matrix; > for "+" use ":+"; How about function "+" (L, R : Matrix) return Matrix is Result: Matrix := L; begin Result :+ R; return Result; end "+"; > 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. Maybe I'm missing something, but I don't see why these concerns are any different than they would be for any other function or procedure. > ------- > 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?