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,d2c21e8238e985b5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-26 22:01:33 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!news-hog.berkeley.edu!ucberkeley!newshub.sdsu.edu!west.cox.net!cox.net!news-east.rr.com!chnws02.ne.ipsvc.net!cyclone.ne.ipsvc.net!24.128.8.70!typhoon.ne.ipsvc.net.POSTED!not-for-mail Message-ID: <3CF1BE0C.8020704@attbi.com> From: "Robert I. Eachus" Organization: Eachus Associates User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020314 Netscape6/6.2.2 X-Accept-Language: en,pdf MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Extended modal types References: <3CEDFF90.B94D7E32@yahoo.com> <5ee5b646.0205250757.60c9715a@posting.google.com> <874rgwt6jf.fsf@deneb.enyo.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 27 May 2002 04:57:18 GMT NNTP-Posting-Host: 24.61.239.24 X-Complaints-To: abuse@attbi.com X-Trace: typhoon.ne.ipsvc.net 1022475438 24.61.239.24 (Mon, 27 May 2002 00:57:18 EDT) NNTP-Posting-Date: Mon, 27 May 2002 00:57:18 EDT Xref: archiver1.google.com comp.lang.ada:24845 Date: 2002-05-27T04:57:18+00:00 List-Id: Florian Weimer wrote: > (IMHO, modular types whose modular type whose modulus is not a power > of two should have been avoided altogether.) Shows your hardware bias. ;-) There are two very useful applications of modular types in Ada. One where the modulus is an integral power of two maps nicely to a lot of hardware device interfaces, etc. The other is in the area of cryptography and hashing, where the modulus tends to be a prime, or the product of two primes. On a lot of hardware (X * Y) mod some large prime is a very useful operation, and maps neatly to a 32-bit by 32-bit multiply with a 64 (actually 63) bit result, and a divide by a 32 bit integer keeping the remainder. Most programming languages have no easy way of getting to those hardware instructions. Are there operations on modular types which are pretty useless for non-power of two modulii, and there are operations that are only of interest for such modulii. Ada supports both, and there is a large enough set of operations that make sense for both that the two sets of types were unified. (Except in the limits in package System.)