[MLton] Callback to function pointer?

Wesley W. Terpstra wesley@terpstra.ca
Sat, 16 Jul 2005 00:36:53 +0200


On Fri, Jul 15, 2005 at 06:10:45PM -0400, Matthew Fluet wrote:
> > So I think it makes sense to stick with _import * (which, by the way
> > Matthew must have slipped the currying by me in my sleep :-).

I just don't get what the problem with currying is. :-P

> the common case would be:
> 
> local
>    val (get_double, set_double) =
>       _symbol * : real;
>    val epsilon_ptr = DynLink.dlsym (hndl, "epsilon")
> in
>    val get_epsilon = fn () => get_double epsilon_ptr
>    val set_epsilon = fn e => set_double (epsilon_ptr, e)
> end

Actually, this does seems sufficiently elegant now that I see it.
So, I suppose I am not against this solution either.
In the end, any syntax makes me happy; it's the function I want.

My only concern in this code snippet is that '_symbol * : real;' didn't
specify the type of MLton.Pointer.t. Where is DynLib.fptr?

I will note that type inference might work here too...

-- 
Wesley W. Terpstra