<html><head><base href="x-msg://385/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Finally got a chance to check this out.<div>It turns out that the expression</div><div><br></div><div><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 12px;">-FIRST(INTEGER)<br><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; "><br></span></span></font></div><div>actually does overflow at compile time, so it is actually a compile-time error to write:</div><div><br></div><div><font class="Apple-style-span" face="Courier">CONST v = </font><span class="Apple-style-span" style="font-size: 12px; "><font class="Apple-style-span" face="Courier">-FIRST(INTEGER);</font></span></div><div><br></div><div>Even worse, on a system where overflow causes a trap that code in Lex.m3 would have failed.</div><div><br></div><div>The expression you wrote doesn't overflow at compile-time, so it is much safer, allowing:</div><div><br></div><div><div><font class="Apple-style-span" face="Courier">CONST v = Word.Plus(</font><span class="Apple-style-span" style="font-size: 12px; "><font class="Apple-style-span" face="Courier">-(FIRST(INTEGER)+1), 1);</font></span></div><div><font class="Apple-style-span" face="Courier"><br></font></div><div>Good catch!</div></div><div><br></div><div><font class="Apple-style-span" face="Courier" size="3"><span class="Apple-style-span" style="font-size: 12px;"><span class="Apple-style-span" style="font-family: Helvetica; font-size: medium; ">On 24 Jan 2010, at 05:57, Jay K wrote:</span><br></span></font><div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">Imagine if FloatMode worked.<br>And if the compile-time evaluation wasn't performed.<br>This code would fail.<br> <br> <br>Though really..you know.. I don't think making FloatMode work makes sense.<br>It should be an interface/type thing that determines statically at compile time<br>if overflow is trapped.<br> <br> <br> - Jay<br> <br>> From:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>> Date: Sun, 24 Jan 2010 04:28:01 -0500<br>> To:<span class="Apple-converted-space"> </span><a href="mailto:jkrell@elego.de">jkrell@elego.de</a><br>> CC:<span class="Apple-converted-space"> </span><a href="mailto:m3commit@elegosoft.com">m3commit@elegosoft.com</a><br>> Subject: Re: [M3commit] CVS Update: cm3<br>><span class="Apple-converted-space"> </span><br>> I really don't like this...<br>> what's wrong with allowing compile-time overflow other than that it exposes 2-s complement representation?<br>><span class="Apple-converted-space"> </span><br>> On 23 Jan 2010, at 20:42, Jay Krell wrote:<br>><span class="Apple-converted-space"> </span><br>> > CVSROOT: /usr/cvs<br>> > Changes by: jkrell@birch. 10/01/23 20:42:28<br>> ><span class="Apple-converted-space"> </span><br>> > Modified files:<br>> > cm3/m3-libs/libm3/src/fmtlex/: Lex.m3<span class="Apple-converted-space"> </span><br>> ><span class="Apple-converted-space"> </span><br>> > Log message:<br>> > oops 1 => 1L<br>><span class="Apple-converted-space"> </span><br></div></span></blockquote></div><br></div></body></html>