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-19 16:19:32 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: += in ada Date: 19 Oct 2003 19:19:29 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1066224357.499523@master.nyc.kbcfp.com> <1066231159.711433@master.nyc.kbcfp.com> <1066311805.222491@master.nyc.kbcfp.com> <3F8F3077.60402@comcast.net> <3F900F35.50203@comcast.net> NNTP-Posting-Host: pip1-5.std.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1066605570 19250 192.74.137.185 (19 Oct 2003 23:19:30 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sun, 19 Oct 2003 23:19:30 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:1157 Date: 2003-10-19T19:19:29-04:00 List-Id: 18k11tm001@sneakemail.com (Russ) writes: > Yes, and there is a huge difference between 100000.0 and 1000000.0 > too. There is a huge difference between X := Y * 2 and X := Y + 2. > There is a huge difference between X <= Y and X >= Y. So what? I have > no trouble distinguishing between them, and I have no trouble > distinguishing between := and :+. They look as different as day and > night to me. I agree that X <= Y and X >= Y can be distinguished easily. But 100000.0 and 1000000.0? They look almost the same to me. A good Ada programmer would write 100_000.0 and 1_000_000.0. In C (etc), you can't do that. I still don't get what you think is so important about these increment operators. It would certainly be convenient if there were a built-in way to increment a variable without writing the variable name twice, especially when the variable name is something complicated like A[I].C.all. Is that what you're getting at? Or do you insist that "A[I].C.all :+ 1" or "A[I].C.all += 1" is somehow much more readable than "Inc(A[I].C.all)"? Or, in pseudo-COBOL, "Add 1 to A[I].C.all"? What about the fact that += in C can have side effects? That is, you can say "while (x += 7)...", using both the *result* of +=, and its effect of addition. I consider that bad. Do you? The best solution to this, in my opinion, would be to allow one to write: procedure Inc(X: in out Root_Integer'Class); This would require that the type Root_Integer (from which all integer types are ultimately derived, in Ada) to be nameable, and it would require the class of all such types to be nameable via 'Class. Such a facility would be quite powerful and quite useful. And of course Inc could easily be predefined. And some folks might prefer it called by infix ":+" or some such (not me). What I don't get, though, is why you think such notations are so *important*. Yes, C has a nice notation +=. Yes, many languages have inherited that notation. So what? It's just plain silly to suggest that this notation is responsible for those languages' popularity, or that the lack of such notations leads inevitably to the demise of Ada. I do agree with you that it would be nice to have a notation for incrementing a variable without naming that variable twice. And I do agree with you that "procedure Inc" is not a good solution (in current Ada) because it requires a separate Inc procedure for every integer type. - Bob