[MLton] NLFFI

Stephen Weeks MLton@mlton.org
Fri, 2 Jul 2004 08:26:49 -0700


> Also, note that dlsym requires you to present the "string" corresponding
> to the symbol you are quering.  On the ML side, there isn't anything to
> prevent you from constructing this string dynamically, but in practice,
> anything coming out of mlnlffi-gen is going to have a constant string.
> So, it's just a question of statically linking in the appropriate library.

Cool.  My worry only comes from a lack of experience with
dl{close,open,sym}, and whether it might not be so easy to port.


Regarding _dimport, would it be possible to think of _dimport as the
primitive and implement _import in terms of _dimport by adding another
primitive like _symbol?  So,

	_import "f": int -> unit;

expands to

	_dimport _symbol "f": int -> unit;


> This reminds me of yet another annotation I wanted to add to .mlbs.  It
> would be great to be able to specify additional linker options.  For
> example, the mini-gtk guys have Makefile calls like:
> 
>         mlton -output buttons-galore-mlton -verbose 1 \
>               -link-opt "`pkg-config --libs gtk+-2.0`" \
>               -link-opt mgtk-mlton.o \
>               buttons-galore-mlton.cm
> 
> It would be great if we could put those link-opt's into mgtk.mlb.

I'm not so sure.  I'm worried it will lead us down a path of including
more and more of the functionality of Makefiles in mlb files.  Think
of cases where one wants to start doing complicated things based on
the platform or run shell commands.  Makefiles already work well for
this sort of thing and I'd hate to start re-implementing that.

For now, I'd like to keep the mlb files more focused on being in the
clean SML world and having a clean semantics.  To solve the above
problem, it seems better to me to adopt some convention or let our
users figure one out, like including a top-level Makefile in each
distributed library that has a phony "mlton-compile-options" target
that prints out the needed options.  Yeah, it's not so composable or
clean, but that may be a more accurate reflection of the real world
than putting annotations in mlbs.