<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> > Word.LeftShift(..., 100); (* where 100 >= BITSIZE(INTEGER),<BR></DIV></SPAN></BLOCKQUOTE>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>My mistake, it does generate a warning.</DIV>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>It also seems to not generate the code to do the shift, good.</DIV>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>I had probably hidden 100 behind a function call, inhibiting the front end's checking.</DIV>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage> Or more likely behind something else. I have to look into something. <BR></SPAN><BR><BR></DIV></BLOCKQUOTE>
<DIV> > Why can't a backend simply generate code for the large shift, as if it had been a call to Word.Shift(..., 100)?</DIV>
<DIV> </DIV>
<DIV>It would be dead/unreachable code, but not a big deal. It looks like the front end skips the code when it can figure it out. I'll have to look into this more, but it is acting different/better than I realized.</DIV>
<DIV> </DIV>
<DIV><BR></DIV>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>[Jay] EVAL -FIRST(INTEGER);<BR>[Jay] I believe the frontend should issue a warning.<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV>[Tony] Why? The front-end does not reason about overflow (except when computing compile-time constants). Overflow is a run-time concept!!!!!!!!!!!!!</DIV>
<DIV> </DIV>
<DIV>Because it can often easily prove that overflow will occur.</DIV>
<DIV>It is worth warning about?</DIV>
<DIV> </DIV>
<DIV>if I write:</DIV>
<DIV> </DIV>
<DIV>a := 1 + 2;</DIV>
<DIV> </DIV>
<DIV>does the front end not optimize that to:</DIV>
<DIV> </DIV>
<DIV>a := 3;</DIV>
<DIV> </DIV>
<DIV>? Imho it should 1 + 2 provably at compile time does not overflow.</DIV>
<DIV> </DIV>
<BR>
> how to enable overflow<BR>
<BLOCKQUOTE><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span>
<DIV style="FONT-FAMILY: Verdana; FONT-SIZE: 10pt" class=ecxhmmessage>> The correct thing to do is introduce different interfaces/modules/types/functions<BR>> which either always do overflow checking, or, perhaps but less likely,<BR> > new interfaces/modules/types/functions that are runtime configurable, as<BR>> INTEGER was originally speced.<BR></DIV></SPAN></BLOCKQUOTE>
<DIV><BR></DIV>
<DIV> > NOOOOO!!!!!!! That will impose an undue expense on targets where such checking is expensive.</DIV>
<DIV> </DIV>
<DIV> I doubt I suggested what you think I did.</DIV>
<DIV> If someone really needs overflow checking, then it will cost them whatever it costs them, on whatever target they care about.</DIV>
<DIV> I am NOT suggesting changing any existing interface/module/type. In fact I am proposing that FloatMode's hypothetical feature to enable overflow checking be removed. That "a + b", "a * b" etc., where a is INTEGER, never ever get overflow checking.</DIV>
<DIV>If anyone needs it, they'd use some as yet to be specified and implemented type/interface/module.</DIV>
<DIV>Like INTERFACE IntOv; TYPE T = INTEGER; PROCEDURE Add(a, b: T) RAISES Something: T;</DIV>
<DIV>etc.</DIV>
<DIV> </DIV>
<DIV>or maybe a new compiler-builtin type INTEGEROV.</DIV>
<DIV>Maybe use the word "safe" as it is popular for this sort of thing (search the web for "safeint").</DIV>
<DIV> </DIV>
<DIV><SPAN style="TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Helvetica; WHITE-SPACE: normal; LETTER-SPACING: normal; WORD-SPACING: 0px" class=ecxApple-style-span><BR> - Jay</DIV></SPAN> </body>
</html>