[M3devel] cm3 regression

Mika Nystrom mika at async.caltech.edu
Wed Apr 16 17:17:23 CEST 2008


Jay writes:
>--_17f831a5-9311-459c-8ba3-fd6675a58221_
>Content-Type: text/plain; charset="iso-8859-1"
>Content-Transfer-Encoding: quoted-printable
>
>
>[tangential...]
>
>I think the definition of INTEGER is OK, but it'd be nice imho for the lang=
>uage or m3core to also build-in UINTEGER, INT8, INT16, INT32, INT64, UINT8,=
> UINT16, UINT32, UINT64, just so folks wouldn't have to provide them themse=
>lves. (CARDINAL I don't think is what I want.)
>Add them somewhere in m3core?
>MODULE Integers; ?

I don't see why you can't provide all these types for yourself in
a library that users can import or not as they see fit... as long
as my old INTEGER programs are still going to use the "default fast
integer type" on the machine!  I can see your arguments for using
such pre-defined fixed-width types inside system-dependent compiler
bits or specific system-dependent source files even in other situations.
(Although I would still argue that part of the point of Modula-3 is
to get away from this kind of system-dependent-everything programming!
Write once, run anywhere!  Oops, am I using someone else's slogan?)

>
>Unfortunately, actually, I want more than this, and then coming up with nam=
>es is hard.
>
>I want "safe" integers that raise exceptions or something upon overflow.

INTEGER/CARDINAL?  You could just name yours INTEGER32, CARDINAL64, etc.
According to the Green Book, overflows for these types are supposed to
raise exceptions or cause some other kind of runtime error.  (Actually,
I am not sure it says so explicitly, but that is definitely the simplest
interpretation of what it does say.)

If you want exceptions on overflow, you do want CARDINAL, not UINTEGER.
Or what would you like 4-5 to return in this "exceptional unsigned" 
integer type?

>I want "unsafe" integers that silently "wrap around".

Word.T?  Word128.T? 

By the way there is nothing "unsafe" about this.  "Unsafe" has a
very specific meaning to Modula-3 people, which I think it would
be nice if we could maintain at least on the "m3devel" mailing list!
See sections 2.1 (first paragraph of the language definition),
2.5.7, and 2.7 of the Green Book.

>And maybe "arbitrary precision" integers that grow to accomodate, but also =
>are smart and shrink to throw away trailing zeros.

Isn't there already a library for this in CM3?

     Mika





More information about the M3devel mailing list