[M3devel] the meaning of -FIRST(INTEGER)?
Jay K
jay.krell at cornell.edu
Wed Jan 20 12:40:03 CET 2010
So..I have m3back using Target.Int a bunch.
And converting back and forth some between Target.Int and
INTEGER and doing match with Target.Int.
And various operations can fail.
And my current diff results in:
new source -> compiling Lex.m3
"..\src\fmtlex\Lex.m3", line 227: doneg: Negate overflowed
"..\src\fmtlex\Lex.m3", line 343: doneg: Negate overflowed
2 errors encountered
new source -> compiling Scan.i3
which is nice to see, it means my code is actually running.
So I look at the code in question:
PROCEDURE ReadNumber(rd: Rd.T; defaultBase: [2..16]; signed: BOOLEAN): Word.T
VAR c: CHAR; sign: [0..1]; res: Word.T; BEGIN
...
IF signed AND
((sign = 0 AND Word.GT(res, LAST(INTEGER))) OR
(sign = 1 AND Word.GT(res, -FIRST(INTEGER)))) THEN
RAISE FloatMode.Trap(FloatMode.Flag.IntOverflow)
....
-FIRST(INTEGER).
What is that supposed to do?
I mean, I kind of know, I'm slightly playing stupid, partly not.
Does the compiler know what is an INTEGER vs. what is a "Word"?
Or it is just obligated to assume everything is a Word?
To do the negation at compile time and ignore the overflow?
Does the language need work here?
I mean, like, -FIRST(INTEGER), that is a problematic expression, isn't it?
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100120/70e3767e/attachment-0001.html>
More information about the M3devel
mailing list