[MLton] Callback to function pointer?
Tue, 12 Jul 2005 16:54:56 -0500
I think that it is quite unfortunate that the semantics of _export are really
more like assignment to a static (per-textual occurance I guess) then like
declaration. Actually, I am rather confused about just what the semantics
are supposed to be. Is something like the following supposed to be legal?:
fun f (x: 'a) =
let fun thunk () = x
in (_export "zulu": unit -> 'a) thunk
(It is rejected.) If it were expected, would there be one cell total for
zulu's? One per type?
Given the flat and global nature of the export name space, wouldn't it be
better if the type of
_export "<C name>": 'a
was a 'a ref? (Or perhaps a 'a option ref, initially NONE/NULL?) Then the
assignment nature would be clear and the semantics would be that the value of
the _export ... was to look up the global ref cell associated to the name and
to return it.