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!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Efficiency of code generated by Ada compilers Date: Wed, 11 Aug 2010 09:38:11 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1jn1a4o.1dfllwo1uin3imN%csampson@inetworld.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1281533866 14635 192.74.137.71 (11 Aug 2010 13:37:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 11 Aug 2010 13:37:46 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:jzZODEQgUMrDfOY9zX2qUSu6ZnY= Xref: g2news1.google.com comp.lang.ada:13120 Date: 2010-08-11T09:38:11-04:00 List-Id: 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 "+". I object to having built-in support for angle arithmetic in the language, though. 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. - Bob