[M3devel] INTEGER

Mika Nystrom mika at async.async.caltech.edu
Thu Apr 29 20:59:43 CEST 2010


hendrik at topoi.pooq.com writes:
>On Thu, Apr 29, 2010 at 11:07:00AM -0500, Rodney M. Bates wrote:
>> Oh, I get it!  You are proposing a _mixed_ approach, where the values
>> the programmer can designate are of fixed (though possibly nonstatic)
>> size (like open arrays) but the intermediate results are of unbounded
>> size that re-adapts to hold the actual value each time an operator is
>> evaluated, (like BigInteger).  And because only intermediate results
>> work this way, they can be stack allocated, because intermediate
>> results have LIFO lifetimes.
>
>In fact, the sizes of intermediate results can be determined statically, 
>in theory, at least.  An arithmetic operation with subranges as 
>arguments has at most a finite number of possible argument pairs, and 
>therefore at mist a finite number of possible results.  A finite set of 
>integers has a maximum and a minimum.
>
>In practices, there might be operations (such as shifts and 
>exponentiation) for which there bounds are impractical.
>
>-- hendrik

Well, the language only has built-in operations for which the range
checks are easy.

The problem with only allowing static sized LONGINTs is that you can't
write

PROCEDURE F(READONLY a, b : LONGINT; VAR c : LONGINT) =
  BEGIN c := a + b END F;

Instead you get a proliferation of Fs to cover every possible range...

I suppose you can do it with generics but oh what a pain.

     Mika



More information about the M3devel mailing list