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,54889de51045a215 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-10-19 23:16:23 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: 18k11tm001@sneakemail.com (Russ) Newsgroups: comp.lang.ada Subject: Re: += in ada Date: 19 Oct 2003 23:16:22 -0700 Organization: http://groups.google.com 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: 63.194.87.148 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1066630582 15631 127.0.0.1 (20 Oct 2003 06:16:22 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 20 Oct 2003 06:16:22 +0000 (UTC) Xref: archiver1.google.com comp.lang.ada:1177 Date: 2003-10-19T23:16:22-07:00 List-Id: Robert A Duff wrote in message news:... > 18k11tm001@sneakemail.com (Russ) writes: > I still don't get what you think is so important about these increment > operators. I admit that I'm probably making too much of them, and I hereby apologize to everyone for my rudeness. They just seem like a good idea to me for several reasons, and I am a bit obsessive/compulsive, so I have a hard time letting it go. > 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? That's part of it. > 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"? I think there should be one standard that can be overloaded for user-defined types. I think ":+" is a good candidate for that standard, but "Inc" would do, I suppose (with a default argument of 1). Unfortunately, "Inc(A,B)" for vector matrix addition leaves a lot to be desired. The nice thing about "+=" or ":+" is that they look right for both integers and matrices. > 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? Yes, I do, but it would not be an issue in Ada because "+=" or ":+" would be a procedure, and as such it wouldn't return a value. So the example you give above would not be valid. > 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). As I said, ":+" is more versatile. It applies both to integer incrementation *and* vector/matrix addition. > 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. At some point one must ask *why* Ada is so unpopular, despite the fact that the DoD forced its use on a massive scale. Yes, the DoD mandate created some resentment, but if Ada is really so good, those who adopted it under duress should have eventually learned to appreciate it. Many did, I realize, but why are so many of them now rushing to throw off the yoke? Yes, I realize that the issue is complex and many "higher-level" problems exist, such as lack of standard libraries, development tools, etc. But then you have to ask why those problems developed in the first place. I just think that the root cause of Ada's lack of popularity, when you get right down to it, is the awkward syntax, notably ":=", and perhaps to a lesser extent the lack of "+=" type operators. Can I prove this? No, but I have a truckload of circumstantial evidence for it. I've been over this before. Think of the most popular languages in existence: C, C++, Java, Perl, Python, Fortran, Basic, COBOL, even Matlab and Mathematica. Every one of them uses "=" for assigment. Now name one wildly popular language that does *not* use "=" for assignment. You can't do it. And no, Pascal and Modula are not what I call wildly popular. I realize that standard Ada is stuck with ":=", of course. However, I have developed a relatively simple pre-processor that effectively implements a dialect of Ada that uses "=". I call it "MyAda". I also have the inverse pre-processor, so I can go in both directions. With a few additional utilities, it should be possible for a member of an Ada devepment team to use MyAda without anyone else on the team ever even knowing. I realize that this is a long shot, but as I said, I am a bit obsessive/compulsive. > 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. Thanks for acknowledging that.