<html><head><base href="x-msg://991/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-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; orphans: 2; text-align: auto; 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: 0; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; 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; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><span class="Apple-style-span" style="font-size: medium;"><font class="Apple-style-span" color="#0000FF" face="'Gill Sans'">The patch I sent to you yesterday will achieve checked assignment of LONGINT to/from INTEGER.</font></span></div></span></span></span></span></span></span></span></span></div></span></span>
</div>
<br><div><div>On 9 Jan 2010, at 04:04, Jay K wrote:</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; ">Uh, maybe all ordinal types that overlap in any values are assignable?<br> <br> <br>PROCEDURE IsAssignable (a, b: T): BOOLEAN =<br> VAR i, e: T; min_a, max_a, min_b, max_b, min, max: Target.Int;<br> BEGIN<br> IF IsEqual (a, b, NIL) OR IsSubtype (b, a) THEN<br> RETURN TRUE;<br> ELSIF IsOrdinal (a) THEN<br> (* ordinal types: OK if they have at least one member in common. *)<br> IF 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> ELSIF IsSubtype (a, b) THEN<br> (* may be ok, but must narrow rhs before doing the assignment *)<br> RETURN IsSubtype (b, Reff.T)<br> OR ArrayType.Split (b, i, e)<br> OR (IsSubtype (b, Addr.T)<br> AND (NOT Module.IsSafe() OR NOT IsEqual (b, Addr.T, NIL)));<br> ELSE<br> RETURN FALSE;<br> END;<br> END IsAssignable;<br><br> <br>?<br>I'll try it out.<br> <br> <br>What is an ordinal type?, I wonder, the compiler implementation:<br> <br> <br>PROCEDURE IsOrdinal (t: T): BOOLEAN =<br> VAR u := Check (t); c := u.info.class;<br> BEGIN<br> RETURN (c = Class.Integer) OR (c = Class.Longint) OR (c = Class.Subrange)<br> OR (c = Class.Enum) OR (c = Class.Error)<br> OR ((c = Class.Packed) AND IsOrdinal (StripPacked (t)));<br> END IsOrdinal;<br><br> <br> - Jay<br><br><br><br><br><br> <br><hr id="stopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: RE: [M3devel] latest longint file size diffs<br>Date: Sat, 9 Jan 2010 07:52:29 +0000<br><br>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<span class="Apple-converted-space"> </span><br><br>either:<br> is true<br> or false<span class="Apple-converted-space"> </span><br> or raises an exception<span class="Apple-converted-space"> </span><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<span class="Apple-converted-space"> </span><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="ecxstopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sat, 9 Jan 2010 07:01:47 +0000<br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] latest longint file size diffs<br><br><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="ecxecxstopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>To:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: RE: [M3devel] latest longint file size diffs<br>Date: Sat, 9 Jan 2010 06:59:52 +0000<br><br>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; <span class="Apple-converted-space"> </span><br> INTEGER first := 16_80;<span class="Apple-converted-space"> </span><br> INTEGER p1 := max + 1;<span class="Apple-converted-space"> </span><br> LONGINT p1L := max + 1L;<span class="Apple-converted-space"> </span><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="ecxecxecxstopSpelling">From:<span class="Apple-converted-space"> </span><a href="mailto:hosking@cs.purdue.edu">hosking@cs.purdue.edu</a><br>Date: Sat, 9 Jan 2010 01:03:08 -0500<br>To:<span class="Apple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>CC:<span class="Apple-converted-space"> </span><a href="mailto:m3devel@elegosoft.com">m3devel@elegosoft.com</a><br>Subject: Re: [M3devel] latest longint file size diffs<br><br><div><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div style="word-wrap: break-word; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal 12px/normal Helvetica; white-space: normal; letter-spacing: normal; color: rgb(0, 0, 0); word-spacing: 0px; "><div><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-interchange-newline"><blockquote><span class="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">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="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; ">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="ecxecxecxecxApple-style-span" style="text-transform: none; text-indent: 0px; border-collapse: separate; font: normal normal normal medium/normal Helvetica; white-space: normal; letter-spacing: normal; word-spacing: 0px; "><div class="ecxecxecxecxhmmessage" style="font-family: Verdana; font-size: 10pt; "><br> - Jay<br><br><br>> From:<span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><a href="mailto:jay.krell@cornell.edu">jay.krell@cornell.edu</a><br>> CC:<span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>> Looking at your code, I think the assignability test for ordinals should be more like:<br>><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>> That way CARDINAL and other subranges fall right out.<br>><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxecxApple-converted-space"> </span><br>><span class="ecxecxecxecxApple-converted-space"> </span><br>> On 8 Jan 2010, at 06:13, Jay K wrote:<br>><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxecxApple-converted-space"> </span><br>> > FOR statements also don't allow the level of mixing<br>> > that they should.<br>> ><span class="ecxecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxecxApple-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="ecxecxecxecxApple-converted-space"> </span><br>> ><span class="ecxecxecxecxApple-converted-space"> </span><br>> > - Jay<br>> > <dif8.txt><br>><span class="ecxecxecxecxApple-converted-space"> </span><br></div></span></blockquote></div><br></div></span><br class="Apple-interchange-newline"></blockquote></div><br></body></html>