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-17 08:48:23 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!nntp.giganews.com!wn14feed!worldnet.att.net!204.127.198.203!attbi_feed3!attbi.com!rwcrnsc53.POSTED!not-for-mail Message-ID: <3F900F35.50203@comcast.net> From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.2) Gecko/20021120 Netscape/7.01 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: += in ada References: <49cbf610.0310101231.2358762a@posting.google.com> <1066224357.499523@master.nyc.kbcfp.com> <1066231159.711433@master.nyc.kbcfp.com> <1066311805.222491@master.nyc.kbcfp.com> <3F8F3077.60402@comcast.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.34.139.183 X-Complaints-To: abuse@comcast.net X-Trace: rwcrnsc53 1066405701 24.34.139.183 (Fri, 17 Oct 2003 15:48:21 GMT) NNTP-Posting-Date: Fri, 17 Oct 2003 15:48:21 GMT Organization: Comcast Online Date: Fri, 17 Oct 2003 15:48:21 GMT Xref: archiver1.google.com comp.lang.ada:1086 Date: 2003-10-17T15:48:21+00:00 List-Id: Russ wrote: > Two characters? Apparently you forgot about, or don't count, having to > write "Inc" in the first place. No, I didn't, I have a package I use when I am doing "serious" development. I will probably post it as the root for an "Eachus" heirarchy here, although I have been calling it Common. It contains Inc for Integer and Character, but the part I use even more than that is a set of TBD declarations. These allow me to say for example: function Do_Something(A, B: Parameters) return Integer is begin return TBD("Do_Something"); end Do_Something; (And yes I do add the optional name to the end automatically, I type pretty fast, and it is easier to always add it than to stop to think.) Of course, now my code compiles cleanly and if I run it, the call to TBD, if called prints a message and raises To_Be_Done. ;-) Very handy feature. Of course, when code is "complete" I want to get rid of the with Common; use Common; so I will cut and paste some declarations like Inc if necessary to do that. I have been thinking of splitting thing and having a separate package "To_Be_Done". > As I said before, I am not an Ada programmer, so perhaps you can help > me understand something. In a large program or software system of your > design, approximately how many versions of "Inc" and the like do you > have floating around just for basic scalar types? I know that Ada > allows, and in fact encourages, the use of specialized types for > everything. Do you need to write an "Inc" procedure for each type? Or > do you perhaps use generics? It may be a failure of my style, but I think it is pretty common for Ada programmers, things you want to increment are almost always Integers or a subtype of Integer. I do have a quirk of writing some Inc calls for Character and other character types, but that is almost certainly due to my involvement with character set issues. (Things like printing tables of Characters and their classification if you use a non-Latin1 character set via compile-time option.) > Whatever the case, wouldn't it be simpler and cleaner to just use a > standard ":+" and let the compiler do it for you? Do you get paid > extra for writing code that the compiler can generate all by itself? > And how many meetings do you need to inform your programmers of your > particular procedure naming conventions when you could avoid all that > with a simple standard for the entire Ada world? I would love to replace the almost useless Character'Succ function with an Inc procedure in the standard, or just add Inc. I wouldn't even mind if it were called Succ instead. But ":+" is a non-starter for me and most Ada programmers. Same goes for Foo++; which, if anything would be much more acceptable to Ada programmers, and which you seem to ignore. (Hmmm. In fact, ++Foo; might be acceptable to most Ada programmers, and should be much more acceptable than Foo++; even though the pre- and post- semantics wouldn't apply to Ada.) > I read all sorts of discussion on this forum about the need for > standard libraries for Ada. Well, why not start at the bottom with > standard symbols for common procedures? C++ has the STL, and it also > has a standard symbol for incrementing a stupid counter. Every > C/C++/Java/Perl/Python programmer in the world is on the same page. > But Ada leaves the naming as an excercize for the programmer, and I'm > sure there are almost as many conventions as programmers. If that > somehow helps "readability", then your definition of "readability" is > not the same as mine. This is where you are just p***ing up a rope. Ada programmers don't LIKE the implied side effects associated with += and other such operators in C. You will never get anyone who does a lot of programming in Ada to accept it. On the other hand for Inc(Foo); and ++Foo; there is one effect, and it is the intended effect, not a side effect. There is a HUGE difference between X += 1; and X := 1; and that is what you are fighting. It is a readability issue. How many times do I have to misread :+ as := to wipe out all the advantage from adding :+ to Ada? Oh, and in C where do you most often use +=? Right, in for loops. (And yes, most good C programmers use ++ more often there than +=.) But in Ada there is an implied increment function in: for I in Foo'Range loop and a decrement in for I in reverse Foo'Range; so even if it was available, :+ in Ada would appear a lot less frequently than += in C. -- Robert I. Eachus "Quality is the Buddha. Quality is scientific reality. Quality is the goal of Art. It remains to work these concepts into a practical, down-to-earth context, and for this there is nothing more practical or down-to-earth than what I have been talking about all along...the repair of an old motorcycle." -- from Zen and the Art of Motorcycle Maintenance by Robert Pirsig