<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Again, I think hand.c's should largely be moved to Modula-3 code.<BR>
e.g. all the "set_*" functions.<BR>
<BR>
(rough uncompiled unfinished) proposal #1 aka "RTHooks".<BR>
<BR>premise:<BR> If the compiler generates calls to it, it ought to be in RTHooks.<BR>
<BR>RTHooks.i3<BR>
<BR>TYPE Set = UNTRACED REF Word.T<BR>TYPE SetBoolean = Word.T; (* a full 32 or 64 bits; C would have returned at least 32 *)<BR>TYPE SetSize = CARDINAL; (* probably too much layering *)<BR>TYPE SetIndex = CARDINAL; (* probably too much layering *)<BR>CONST SetTRUE = 1;<BR>CONST SetFALSE = 0;<BR>
<BR>PROCEDURE SetMember(set: Set; element: SetIndex): SetBoolean;<BR>(* SetTRUE IFF element IN set, else SetFALSE *)<BR>
<BR>
<BR>PROCEDURE SetUnion(inA, inB, out: Set; setSize: SetSize);<BR>(* out := inA + inB *)<BR>
<BR>
<BR>PROCEDURE SetIntersection(inA, inB, out: Set; setSize: SetSize);<BR>(* out := inA * inB *)<BR>
<BR>
<BR>PROCEDURE SetDifference(inA, inB, out: Set; setSize: SetSize);<BR>(* out := inA - inB *)<BR>
<BR>
<BR>PROCEDURE SetSymmetricDifference(inA, inB, out: Set; setSize: SetSize);<BR>(* out := inA xor inB *)<BR>
<BR>
<BR>PROCEDURE SetGE(inA, inB: Set; setSize: SetSize): SetBoolean;<BR>(* ... *)<BR>
<BR>
or longer SetGreaterOrEqual?<BR>
<BR>
<BR>etc.<BR>
<BR>MODULE RTSet (m3-libs/m3core/src/runtime/common/RTSet.m3) EXPORTS RTHooks;<BR>
<BR>...<BR>
<BR>You might also say:<BR>
<BR>
PROCEDURE SetMember(VAR set: Word.T; element: SetIndex): SetBoolean;<BR>
<BR>esp. e.g. on the outputs.<BR>and to capture the invalidity of NULL?<BR>
<BR>
<BR>
(rough uncompiled unfinished) proposal #2 aka "RTSet"<BR>premise:<BR> It seems right.<BR>
<BR>
<BR>RTSet.i3: (m3-libs/m3ore/src/runtime/common/RTSet.i3, or m3-libs/m3core/src/set?)<BR>
It seems prudent to keep the "RT" prefix for global namespace reasons.<BR>
It seems "RT" implies "runtime" directory though.<BR>
I'd worry that calling it just Set.i3 could clash with other code.<BR>
Notice that the existing names in hand.c cannot clash with any Modula-3 code, due<BR>
to the single underscore.<BR>
<BR>
Perhaps perhaps perhaps this is a great reason to leave this all alone, because<BR>
using C enables chosing identifiers in a separate namespace??<BR>
<BR>
<BR>TYPE T = UNTRACED REF Word.T<BR>TYPE Boolean = Word.T; (* a full 32 or 64 bits; C would have returned at least 32 *)<BR>TYPE Size = CARDINAL; (* probably too much layering *)<BR>TYPE Index = CARDINAL; (* probably too much layering *)<BR>CONST True = 1;<BR>CONST False = 0;<BR>
<BR>
<BR>PROCEDURE Member aka In(set: T; element: Index): Boolean;<BR>(* True IFF element IN set, else False *)<BR>
<BR>PROCEDURE Union aka Plus(inA, inB, out: T; size: Size);<BR>(* out := inA + inB *)<BR>
<BR>PROCEDURE Intersect aka Intersection aka Times(inA, inB, out: T; size: Size);<BR>(* out := inA * inB *)<BR>
<BR>PROCEDURE Difference aka Sub aka Subtract(inA, inB, out: T; size: Size);<BR>(* out := inA - inB *)<BR>
<BR>PROCEDURE SymmetricDifference aka Xor(inA, inB, out: T; size: Size);<BR>(* out := inA xor inB *)<BR>
<BR>PROCEDURE GE(inA, inB: T; size: Size): Boolean;<BR>(* ... *)<BR>
<BR>
<BR>etc.<BR>
<BR>
<BR>I'm undecided on the names.<BR>But I think I prefer:<BR> Union, Intersect, Difference, SymmetricDifference, Member, GE, EQ, NE, LT, LE, GT.<BR>
<BR>
<BR>It definitely looks nicer to put things in RTSet.<BR>
(Assuming people believe "name scoping" is a good idea. There are<BR>
counter arguments -- one flat global namespace is more conducive to search...)<BR>
<BR>But the precedent of putting "everthing" in RTHooks seem clear.<BR> Though it is violated by hand.c..because it doesn't matter.<BR> You could declare them as extern in RTHooks.i3 and it wouldn't make<BR> any difference. The names are "never" referenced by Modula-3 code.<BR> Well, ok, m3back.m3 has the strings.<BR>
<BR>
<BR>
I guess I'll do whittle at it a little more before doing this -- remove the tables, at least the NT386 exported ones.<BR>
<BR>
<BR> - Jay<BR> </body>
</html>