[M3devel] INTEGER

Mika Nystrom mika at async.async.caltech.edu
Tue Apr 27 19:30:36 CEST 2010


Mika Nystrom writes:
...
>I am not worried as you are by the range problem.  The saving grace is
>that the language has very few arithmetic operators on integers.  
>+ - * DIV MOD.  It's not hard to do range arithmetic on these such that
>one can easily figure out how much memory is required to hold intermediate
>results.  If you're happy with alloca (I don't mind it), that's what
>you do.  You have three options in so far as calculating the required
>space:
...

To clarify a bit further, my proposal is that the ranges be lost in
the evaluation.  Everything in the expression is simply of type LONGINT.
When the final result is assigned to a variable, there is a range check
(which can be dispensed with if the compiler can prove that there can
be no overrun).

Isn't this how INTEGER subranges work?

a : [0..2];
b : [0..1];

a := 4*b - 2*b

     Mika



More information about the M3devel mailing list