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-Thread: 103376,2a34b7ad6c6a0774 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.nethere.com!news.nethere.com.POSTED!not-for-mail NNTP-Posting-Date: Thu, 12 Aug 2010 02:48:40 -0500 Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers From: csampson@inetworld.net (Charles H. Sampson) Date: Thu, 12 Aug 2010 00:48:39 -0700 Message-ID: <1jn35js.5fepcoxaz04uN%csampson@inetworld.net> References: <1jn1a4o.1dfllwo1uin3imN%csampson@inetworld.net> User-Agent: MacSOUP/2.8.2 (Mac OS X version 10.4.11 (PPC)) X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-36AI9TuFOWUbNX6FKRvsnBK5WnAJUPP9Np0KwpswDNz0gcvI2zi1LXEKWSI1OtPPBWf9mvTuX+CRiWT!b1GtrIPqWLVlxPhNT3tD7vMroCwGgncrzw1MdVVyQB9mtP94gVG8NuAl0tsUOeJONG1p9eHtqoxJ!Duw2s0jHg7hvPRZ4mgsHC7uKk3oy X-Complaints-To: abuse@nethere.com X-DMCA-Complaints-To: abuse@nethere.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Xref: g2news1.google.com comp.lang.ada:13158 Date: 2010-08-12T00:48:39-07:00 List-Id: Robert A Duff wrote: > csampson@inetworld.net (Charles H. Sampson) writes: > > > wrote: > > >> Bearing := (Bearing + Turn_Angle) mod 360; > > > > I'd be interested in hearing reactions to something I did. ... > > > I then overloaded "+" and "-" for (Bearing, Turn_Angle) arguments > > and Bearing return value. In those functions is where the mod 360 > > occurred. (Actually, mod 360.0, as it were.) > > > > There were two advantages to doing that. The more important was > > that previously both of the kinds of values were being represented as > > subtypes of Long_Precision and programmers would occasionally > > interchange them and cause big debugging problems. The second was > > removing the "mod" from sight, which allowed the programmers to simply > > think of taking a bearing, turning an angle, and getting the resulting > > bearing, without worrying about all the niceties that might be going on > > inside "+". > > Sounds to me like a good way to do things. It would still be a good > idea if you called it "Turn_Left" or something like that, instead > of "+". But I don't object to "+". This was for the U. S. Navy, and "positive is right" is pretty much universal. For programmers, that is, not for sailors. They think port and starbord. > I object to having built-in support for angle arithmetic in the > language, though. I don't follow. What is angle arithmetic? Whatever it is, it sounds too specific for a general purpose language. > Did you eliminate meaningless ops like "*"? You could do that > by making the types private, but then you lose useful things > like literal notation. Or you could declare "*" to be > abstract, which is an annoyance, but might be worth it. I would have liked to eliminate meaningless ops. As you noted, making the types private results in the loss of literals. I wasn't ready to go that far. What I really want is a way to hide existing visible operations, particularly the ones from Standard. I've asked about it before and there doesn't seem to be too much enthusiasm, not enough to warrant the time to get the niggling details correct. The problem is, you can't write something like if Current_Bearing + 0.5 > 180.0 because it's ambiguous. (Is "+" from Standard or is it the special "+" for bearings and turn angles?) So you end up having to qualify literals when there's only one reasonable "+" in the minds of the programmers. Of course, you won't have that problem if your style is to always use typed constants, but I wasn't ready to go that far either. Charlie -- All the world's a stage, and most of us are desperately unrehearsed. Sean O'Casey