comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-dejanews.com>
Subject: Re: Modular type. What is it and why?
Date: 1999/04/07
Date: 1999-04-07T00:00:00+00:00	[thread overview]
Message-ID: <7egmbf$tgi$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 7edhdi$sb8$1@its.hooked.net

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    




  reply	other threads:[~1999-04-07  0:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-04-05  0:00 Modular type. What is it and why? Staffan Dittmer
1999-04-05  0:00 ` David C. Hoos, Sr.
1999-04-06  0:00   ` Mike Silva
1999-04-06  0:00     ` Mike Silva
1999-04-07  0:00       ` Robert Dewar [this message]
1999-04-07  0:00         ` Bret
1999-04-11  0:00         ` Florian Weimer
1999-04-06  0:00     ` Marin David Condic
1999-04-06  0:00       ` Mike Silva
1999-04-06  0:00         ` bglbv
1999-04-07  0:00         ` Ole-Hjalmar Kristensen
1999-04-07  0:00           ` Mike Silva
1999-04-07  0:00             ` Stephen Leake
1999-04-08  0:00             ` Ole-Hjalmar Kristensen
1999-04-06  0:00     ` Ole-Hjalmar Kristensen
1999-04-05  0:00 ` Marin David Condic
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox