[MLton] Callback functions: how?

Vesa Karvonen vesa.karvonen at cs.helsinki.fi
Thu Feb 15 13:19:34 PST 2007

Quoting Henry Cejtin <henry.cejtin at sbcglobal.net>:
> you could use a trick  like this: you use an array instead of a hash table, as
> discussed, but the void * argument isn't an  integer  but  a  pointer  to  an
> integer  (pointing into the C heap).  This way you can re-number the integers
> pointed to when the array becomes too sparsely occupied.  It  costs  you  one
> level of indirection (to get the int) but is safe for space.

Indeed, as Teal'c would say it.  That is roughly the idea that my PtrCache uses:


The array isn't sparse, however.  All the values are eagerly packed to the
beginning of the array while the end of the array may contain empty slots.

-Vesa Karvonen

More information about the MLton mailing list