[M3devel] INTEGER vice INT32
Tony Hosking
hosking at cs.purdue.edu
Thu Dec 17 17:30:47 CET 2009
But we *do* have explicit types in Modula-3. Subranges and BITS FOR let us pretty much do everything we want (the current implementation restrictions are in using underlying in-memory representations for subranges that round to the nearest byte size).
Antony Hosking | Associate Professor | Computer Science | Purdue University
305 N. University Street | West Lafayette | IN 47907 | USA
Office +1 765 494 6001 | Mobile +1 765 427 5484
On 17 Dec 2009, at 11:18, Peter Eiserloh wrote:
> Hi Tony,
>
> Both Jay, and yourself have valid points.
>
> One can classify the two kinds of types, as implicit, and
> explicit.
>
> More specifically, INTEGER is implicit, and is useful for
> in-memory representation. This was especially important
> when machine registers were very different between machines.
> Very few remember the days of 18-bit words, with 9-bit
> bytes (thank you!). An implicit type is very useful,
> when you are not worried about external representation
> and all one needs is the logical behavior of the type,
> independent of the particular machine on which one may
> currently be.
>
> Explicit types are much more useful, if not imperative,
> when defining data types for external storage (in files,
> or network protocols).
>
> For binary file IO many people take a naive approach, and
> simply overlay a data structure onto the file stream.
> This ignores the potential difference in sizes of implicit
> types, and their endianess. A more careful method of
> doing binary files, is to distinguish the external from
> the internal representation, and have procedures to do
> the IO a field at a time. See binIO.
>
> Back in the late 1980's, and early 1990s, I had an Amiga
> computer, and had two different "C" compilers: Aztec, C
> and SAS/C. The Aztec compiler int was 16-bits, whereas
> the SAS/C int was 32 bits. As you can imagine this caused
> all sorts of havoc. The Amiga system includes were
> rewritten with somewhat more explicit types. These were
> macros such as ULONG, SLONG, USHORT, SSHORT, UBYTE, and
> SBYTE.
>
> This illustrates the importance of explicit types.
> Both implicit and explicit types have their place.
>
>
> Peter
>
>
>
> Date: Wed, 16 Dec 2009 20:10:14 -0500
> From: Tony Hosking <hosking at cs.purdue.edu>
> Subject: Re: [M3devel] Oops, forgot to ask
> To: Jay K <jay.krell at cornell.edu>
> Cc: m3devel <m3devel at elegosoft.com>
> Message-ID: <EF60618E-7AE3-4FF9-A805-5B8B83B369E2 at cs.purdue.edu>
> Content-Type: text/plain; charset="us-ascii"
>
>> On 16 Dec 2009, at 19:52, Jay K wrote:
>>
>>> "0..LAST(LONGINT)" having varying meaning...like when INTEGER is > 64
>> bits, then LONGINT=INTEGER, and we anticipate 128 bit INTEGER?
>>>
>>>
>>> See..LONGINT is only useful in this brief period where we still have 32bit INTEGER.
>>> (Actually it would have been useful long ago.)
>>
>> LONGINT could be 128 bits for all its definition cares. It is just
>> something usually (not always) bigger than an INTEGER.
>>
>>> I really think "long" is a dumb name..
>>> There should be INT8, UINT8, INT16, UINT16, INT32, UINT32, INT64,
>> UINT64, and unsigned and signed integers the same size of a pointer,
>> possibly called INT and UINT, or size_t and ptrdiff_t..
>>
>> Now these are dumb names because they wire in the size of the value.
>>
>> In Modula-3 INTEGER is a natural (i.e., word-size) value.
>
>
> +--------------------------------------------------------+
> | Peter P. Eiserloh |
> +--------------------------------------------------------+
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091217/be50c24a/attachment-0002.html>
More information about the M3devel
mailing list