Problem with FFI?

Alastair Reid reid at cs.utah.edu
Fri Jun 21 07:29:20 EDT 2002


John Meacham <john at repetae.net>:
> however i would make one change, only the first
> calls to hs_set_hs_argv and hs_set_prog_argv are honored, after that
> they are ignored, that way if multiple libraries wish to set the
> arguments it wont run into undefined behavior. (since there is no
> way in general to know whether hs_set_* has already been called.)

Hmmm, I don't like interfaces that silently ignore arguments.  How
about if the functions return a bool saying whether arguments got
ignored and then the caller can decide whether they care.

> also, it should be made clear that it is possible to run the haskell
> runtime more than once, as in

>   hs_init
>    c + haskell  stuff
>   hs_fini
>    c stuff
>   hs_init
>    c + haskell stuff
>   hs_fini
>   done

> so libraries which are dynamically loaded and unloaded will work.

I was deliberately ruling that out.  To do this we have to find every
single global variable in the Haskell runtimes and provide an
initializer function to set them back to their initial values.  I'm a
little reluctant to add it to the spec because I'm feeling lazy.... 

--
Alastair




More information about the FFI mailing list