<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Current:<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 there is a common supertype<br> and they have at least one member in common. *)<br> IF IsEqual (Base(a), Base(b), 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><br>my proposed:<br><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>
<br><br>Your proposed:<br><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><br>What's the point of checking the types? Given that they are both ordinal?<br>To restrict certain assignments?<br>Aren't the base types of any ordinal type either Int.T or LInt.T?<br> So the check will always be true?<br>I have to check.<br><br><br> - Jay<br><br> </body>
</html>