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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fcf8ea94b94d6941 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: Modular type. What is it and why? Date: 1999/04/07 Message-ID: <7egmbf$tgi$1@nnrp1.dejanews.com>#1/1 X-Deja-AN: 463787673 References: <7ean3c$79m$1@eol.dd.chalmers.se> <7eb2iq$jc3@hobbes.crc.com> <7ede2p$pd1$1@its.hooked.net> <7edhdi$sb8$1@its.hooked.net> X-Http-Proxy: 1.0 x14.dejanews.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja News - The Leader in Internet Discussion X-Article-Creation-Date: Wed Apr 07 22:31:10 1999 GMT Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-04-07T00:00:00+00:00 List-Id: In answer to the question what is a modular type, perhaps the most important way to answer this is that the most typical use is to provide an unsigned binary integer with wrap around semantics, just like C unsigned, e.g. type x is mod 2 ** 32; provides a type essentially identical to the C type unsigned, presuming that the latter is 32 bits (as usual, there is no way of controlling the size of types in C). Yes, "peculiar" non-binary values can be used for the modulus, and they have some limited uses for addressing circular arrays etc, but in fact this usage is quite marginal. By far the most important use is for binary unsigned. A bit of history here. The URG spent a lot of effort on designing modular (unsigned) types. We had one member who pushed for generalizing this to arbitrary moduli, but this proposal was soundly rejected as a frill. The Ada 95 design team had the mission of incorporating URG suggestions, and they read the report of this one person, thinking it represented URG consensus, and hence Ada 95 has the more general formulation. I still think it is a bit of a frill. Yes, the circular array is the canonical example of its use, but I doubt this is worth the extra complexity of use and definition (look for example at the strange definition of not on non-binary modulus values). And a difficulty is that the resulting types are called modular types, instead of unsigned types, resulting in exactly the confusion represented by the original question here. People can read a general definition of modular types, and easily miss that this is in fact the facility in Ada for providing conventional unsigned types. Anyway, it does make for nice neat examples with circular buffers, though the restriction to static values makes it less useful for this purpose than one might at first imagine. -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own