Introducing the "lookup-constants runtime system" :)

Stephen Weeks MLton@sourcelight.com
Mon, 1 Oct 2001 16:15:48 -0700


> But if some day we're going to do crosscompilation to an
> entirely different system (e.g. a different 64bit CPU or
> something) - things like sizeof() will not work correctly.
> I'm not sure if it matters for crosscompiling the compiler
> itself, but for a programmer crosscompiling with some
> foreign library (like SDL), it might give problems for the
> constants in that library accessed from MLton with _prim.

This is all starting to sound complex enough that we should maybe go with
running the lookup-constants file on the target machine (which is what Henry
proposed initially).  Henry proposed to have lookup-constants do an rsh to the
target machine, which I don't like.  I prefer your solution of having
command-line switches to generate and use the lookup-constants file.  Then, you
only need to rerun the lookup-constants program on the target machine when the
set of primitives changes.  For sanity checking, it would be best to do some
kind of error checking to make sure that the lookup-constants pass is reading in
the values of the constants that it expects.  The easiest thing would be to
print each constant name on a line before printing its value.  Then, when lookup
constants loads the file, it can check.  I also like having the ability to load
a lookup-constants file because one can imagine generating it in other ways or
even hand editing it in certain situations.