[M3devel] RTHook.Set* or RTSet.*?

Jay K jay.krell at cornell.edu
Wed Feb 24 14:15:06 CET 2010


Again, I think hand.c's should largely be moved to Modula-3 code.

e.g. all the "set_*" functions.

 

(rough uncompiled unfinished) proposal #1 aka "RTHooks".


premise:
 If the compiler generates calls to it, it ought to be in RTHooks.


RTHooks.i3


TYPE Set = UNTRACED REF Word.T
TYPE SetBoolean = Word.T; (* a full 32 or 64 bits; C would have returned at least 32 *)
TYPE SetSize = CARDINAL; (* probably too much layering *)
TYPE SetIndex = CARDINAL; (* probably too much layering *)
CONST SetTRUE = 1;
CONST SetFALSE = 0;


PROCEDURE SetMember(set: Set; element: SetIndex): SetBoolean;
(* SetTRUE IFF element IN set, else SetFALSE *)

 


PROCEDURE SetUnion(inA, inB, out: Set; setSize: SetSize);
(* out := inA + inB *)

 


PROCEDURE SetIntersection(inA, inB, out: Set; setSize: SetSize);
(* out := inA * inB *)

 


PROCEDURE SetDifference(inA, inB, out: Set; setSize: SetSize);
(* out := inA - inB *)

 


PROCEDURE SetSymmetricDifference(inA, inB, out: Set; setSize: SetSize);
(* out := inA xor inB *)

 


PROCEDURE SetGE(inA, inB: Set; setSize: SetSize): SetBoolean;
(* ... *)

 

or longer SetGreaterOrEqual?

 


etc.


MODULE RTSet (m3-libs/m3core/src/runtime/common/RTSet.m3) EXPORTS RTHooks;


...


You might also say:

 

PROCEDURE SetMember(VAR set: Word.T; element: SetIndex): SetBoolean;


esp. e.g. on the outputs.
and to capture the invalidity of NULL?

 

 

(rough uncompiled unfinished) proposal #2 aka "RTSet"
premise:
  It seems right.

 


RTSet.i3: (m3-libs/m3ore/src/runtime/common/RTSet.i3, or m3-libs/m3core/src/set?)

It seems prudent to keep the "RT" prefix for global namespace reasons.

It seems "RT" implies "runtime" directory though.

I'd worry that calling it just Set.i3 could clash with other code.

Notice that the existing names in hand.c cannot clash with any Modula-3 code, due

to the single underscore.

 

Perhaps perhaps perhaps this is a great reason to leave this all alone, because

using C enables chosing identifiers in a separate namespace??

 


TYPE T = UNTRACED REF Word.T
TYPE Boolean = Word.T; (* a full 32 or 64 bits; C would have returned at least 32 *)
TYPE Size = CARDINAL; (* probably too much layering *)
TYPE Index = CARDINAL; (* probably too much layering *)
CONST True = 1;
CONST False = 0;

 


PROCEDURE Member aka In(set: T; element: Index): Boolean;
(* True IFF element IN set, else False *)


PROCEDURE Union aka Plus(inA, inB, out: T; size: Size);
(* out := inA + inB *)


PROCEDURE Intersect aka Intersection aka Times(inA, inB, out: T; size: Size);
(* out := inA * inB *)


PROCEDURE Difference aka Sub aka Subtract(inA, inB, out: T; size: Size);
(* out := inA - inB *)


PROCEDURE SymmetricDifference aka Xor(inA, inB, out: T; size: Size);
(* out := inA xor inB *)


PROCEDURE GE(inA, inB: T; size: Size): Boolean;
(* ... *)

 


etc.

 


I'm undecided on the names.
But I think I prefer:
  Union, Intersect, Difference, SymmetricDifference, Member, GE, EQ, NE, LT, LE, GT.

 


It definitely looks nicer to put things in RTSet.

  (Assuming people believe "name scoping" is a good idea. There are

  counter arguments -- one flat global namespace is more conducive to search...)


But the precedent of putting "everthing" in RTHooks seem clear.
  Though it is violated by hand.c..because it doesn't matter.
  You could declare them as extern in RTHooks.i3 and it wouldn't make
  any difference. The names are "never" referenced by Modula-3 code.
   Well, ok, m3back.m3 has the strings.

 

 

I guess I'll do whittle at it a little more before doing this -- remove the tables, at least the NT386 exported ones.

 


 - Jay
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100224/12b93259/attachment-0001.html>


More information about the M3devel mailing list