<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
ok, yeah, it does bug me.<br><br>With 8 bit integer, 16 bit longint.<br><br>Let's replace 128 with 127 + 1.<br><br> (127 + 1) > 127 <br><br>either:<br> is true<br> or false <br> or raises an exception <br><br>"Obviously" it should be true, but implementing that is..uncertain.<br>Though, again, it should really raise the exception before the comparison is made.<br> Maybe it does.<br><br>Where (127 + 1L) > 127 <br><br>is simply true, no controversy..except for the difference with 127 + 1.<br><br>But Rodney said something..that mixed operations fall out of<br>assignability. Right??<br><br><br>I have an idea..I mean..an obvious guess/experiment.<br>I can try providing only for bidirectional assignability<br>and see what the affect on rd/wr is.<br>Maybe bidirectional assignability is enough to<br>keep the diff small?<br>Or, maybe my initial big diff with ORD/VAL everywhere is acceptable?<br> Clearly it will be allowed by any of the proposals, it<br> just might not be necessary.<br><br><br>Also, btw, I think we should warn for truncating assignment.<br>Any time a range check is put in, perhaps.<br>Except maybe not on array indexing.<br>Which might leave this suggestion completely ambiguous as<br>to when a warning should be issued.<br><br>But as has been pointed out, while it may be "annoying" and<br>"inconvenient" to put ORD and VAL everywhere, or at least ORD,<br>it does force us to revisit all those locations where a change<br>is being induced.<br><br>Notice that that the warning may or may not be platform specific.<br>It might trigger only on 32bit platforms.<br>Or the compiler targeting 64bit platforms might "know" about<br>the truncation potential on other platforms and warn.<br>In a specific concrete way, assignment of LONGINT to INTEGER<br>might warn, no matter their current exact sizes.<br><br><br>Extending that rule to subranges might be tricky.<br>TYPE A = [0..LAST(INTEGER)/2];<br>TYPE B = [0..LAST(LONGINT)/2];<br>
VAR a: A; b:B;<br><br>a := b; warn?<br><br>Implementing that, maybe, would require, like a bit carried along<br>with type definitions in the compiler, as to if the definition<br>contains a platform independent size in it...er..<br>if the size is dependent on bitsize(integer) or not, and<br>mixing of that type with any? other type is a warning?<br>Clearly no. Mixing with a type dependent on bitsize(longint)?<br>Maybe.<br><br>I'm not sure what the rule is, but, you know, it'd be nice<br>if above code did warn on 64bit targets, in order to<br>encourage portability to 32bit targets.<br><br><br> - Jay<br><br><hr id="stopSpelling">From: jay.krell@cornell.edu<br>To: hosking@cs.purdue.edu<br>Date: Sat, 9 Jan 2010 07:01:47 +0000<br>CC: m3devel@elegosoft.com<br>Subject: Re: [M3devel] latest longint file size diffs<br><br>
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>
<div> > (LAST(INTEGER) + 1) = FIRST(INTEGER)</div><div><br>ps: a beginner wouldn't necessarily expect this.<br>He might expect an error or widening of precision as needed.<br>Eventually faced with the cruel realities of what can be efficiently implemented,<br>he might accept any of our answers. :)<br><br> - Jay<br></div><br><hr id="ecxstopSpelling">From: jay.krell@cornell.edu<br>To: hosking@cs.purdue.edu<br>CC: m3devel@elegosoft.com<br>Subject: RE: [M3devel] latest longint file size diffs<br>Date: Sat, 9 Jan 2010 06:59:52 +0000<br><br>
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</style>
I'll admit to being a little unsure.<br><br><br>I do hope the rd/wr change can be done with a small diff, maybe nothing outside libm3.<br><br><br>You might classify me more as a lazy user than a language designing deep thinker.<br><br><br>But I'm curious even about your assertion.<br><br><br>Let's pretend INTEGER is 8 bits and LONGINT is 16 bits, ok?<br>It is easier for me.<br><br><br> INTEGER max := 16_7F; <br> INTEGER first := 16_80; <br> INTEGER p1 := max + 1; <br> LONGINT p1L := max + 1L; <br><br><br>So, what happens if we compare p1 with first and p1L with first?<br>Again remember INTEGER is 8 bits, LONGINT is 16 bits.<br><br>p1 will be -128, 0x80.<br>p1L will be 128, 0x0080.<br><br><br>What then happens when you compare 0x0080 to 0x80?<br>Are they equal (truncate both to INTEGER and compare), unequal (sign extend to LONGINT and compare), or you get an exception (upon narrowing the LONGINT to INTEGER and it doesn't fit)?<br><br><br>And heck, shouldn't max + 1 already throw an exception?<br><br><br> - Jay<br><br><br><hr id="ecxecxstopSpelling">From: hosking@cs.purdue.edu<br>Date: Sat, 9 Jan 2010 01:03:08 -0500<br>To: jay.krell@cornell.edu<br>CC: m3devel@elegosoft.com<br>Subject: Re: [M3devel] latest longint file size diffs<br><br>
<div><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><span class="ecxecxecxApple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div><span class="ecxecxecxApple-style-span" style="font-size: medium;">On 9 Jan 2010, at 00:50, Jay K wrote:</span></div></span></span></span></span></span></span></span></span></div></span></span></div><div><br class="ecxecxecxApple-interchange-newline"><blockquote><span class="ecxecxecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="ecxecxecxhmmessage" style="font-size: 10pt; font-family: Verdana;">I don't know the precedence but agreed:<br><br><br>> OR (IsEqual (Base(a), Int.T, NIL) AND IsEqual (Base(b), LInt.T, NIL))<br>> OR (IsEqual (Base(a), LInt.T, NIL) AND IsEqual (Base(b), Int.T, NIL)))<br><br>I was being sort of lazy.<br>I've never touched the front end and it was critical I be able to make<br>a small change and see fairly precisely the expected change, even<br>if I didn't get all cases.<br><br>This is I'm sure why I had to add some VAL/ORD uses, to convert "UINT32"<br>in the Win32 code to INTEGER or LONGINT.<br></div></span></blockquote><div><br></div><div>Yes, that would be why.</div><br><blockquote><span class="ecxecxecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="ecxecxecxhmmessage" style="font-size: 10pt; font-family: Verdana;">Also, I really think mixed arithmetic is ok.<br></div></span></blockquote><div><br></div><div>But are you ok with:</div><div><br></div><div>(LAST(INTEGER) + 1) = FIRST(INTEGER)</div><div><br></div><div>while</div><div><br></div><div>(LAST(INTEGER) + 1L) # FIRST(INTEGER)</div><div><br></div><div>?</div><div><br></div><div>I find such things to be difficult to explain to the novice programmer. Modula-3 was designed using the "principle of least surprise" and I frankly find the above to be very surprising!</div><br><blockquote><span class="ecxecxecxApple-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; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div class="ecxecxecxhmmessage" style="font-size: 10pt; font-family: Verdana;"><br> - Jay<br><br><br>> From:<span class="ecxecxecxApple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>> Date: Sat, 9 Jan 2010 00:37:42 -0500<br>> To:<span class="ecxecxecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>> CC:<span class="ecxecxecxApple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>> Subject: Re: [M3devel] latest longint file size diffs<br>><span class="ecxecxecxApple-converted-space"> </span><br>> Looking at your code, I think the assignability test for ordinals should be more like:<br>><span class="ecxecxecxApple-converted-space"> </span><br>> IF (IsEqual (Base(a), Base(b), NIL)<br>> OR IsEqual (Base(a), Int.T, NIL) AND IsEqual (Base(b), LInt.T, NIL)<br>> OR IsEqual (Base(a), LInt.T, NIL) AND IsEqual (Base(b), Int.T, NIL))<br>> AND GetBounds (a, min_a, max_a)<br>> AND GetBounds (b, min_b, max_b) THEN<br>> (* check for a non-empty intersection *)<br>> min := min_a; IF TInt.LT (min, min_b) THEN min := min_b; END;<br>> max := max_a; IF TInt.LT (max_b, max) THEN max := max_b; END;<br>> RETURN TInt.LE (min, max);<br>> ELSE<br>> RETURN FALSE;<br>> END;<br>><span class="ecxecxecxApple-converted-space"> </span><br>> That way CARDINAL and other subranges fall right out.<br>><span class="ecxecxecxApple-converted-space"> </span><br>> Antony Hosking | Associate Professor | Computer Science | Purdue University<br>> 305 N. University Street | West Lafayette | IN 47907 | USA<br>> Office +1 765 494 6001 | Mobile +1 765 427 5484<br>><span class="ecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxApple-converted-space"> </span><br>> On 8 Jan 2010, at 06:13, Jay K wrote:<br>><span class="ecxecxecxApple-converted-space"> </span><br>> > Attached is my latest work here.<br>> > With the compiler changes (in the diff), I was able to<br>> > elminate most uses of VAL(expr, LONGINT).<br>> > There's something slightly off such that I had<br>> > to add a very small number, like two.<br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> > The compiler change is newer than earlier.<br>> > For example you can now assign CARDINAL to LONGINT.<br>> > I didn't do it, but you should also be able to add/subtract/etc.<br>> > mixing CARDINAL and LONGINT.<br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> > FOR statements also don't allow the level of mixing<br>> > that they should.<br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> > I'm hoping to get agreement soon just from the diffs<br>> > but if necessary I'll look how to create a branch.<br>> > My general worry about branches is developers just<br>> > go off on their own in a branch and it's impossible to<br>> > get anyone to look at it, they are busy enough with one branch,<br>> > let alone multiple..<br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxApple-converted-space"> </span><br>> > - Jay<br>> > <dif8.txt><br>><span class="ecxecxecxApple-converted-space"> </span><br></div></span></blockquote></div><br> </body>
</html>