[MLton] Callback functions: how?
henry.cejtin at sbcglobal.net
Wed Feb 14 15:29:42 PST 2007
For mGtk stuff I use a hash table and the uarg argument is the key (a
Word32.word). The reason I need the hash table is to that unused callbacks
can be GC'd.
The hash table, of course, has its own method of growing, by increasing the
number of buckets when there are enough entries, and of shrinking.
Given the way polymorphism is dealt with and the way that the hash table is
polymorphic, chances are that only registered functions make it into the type
of the list elements, so the dispatch will be restricted to them. To be
safe, you could declare a new datatype (instead of list) to hold a bucket.
Not very nice, and I doubt needed.
More information about the MLton