Changes between Version 12 and Version 13 of ForeignFunctionInterface


Ignore:
Timestamp:
Oct 9, 2009 11:12:20 AM (5 years ago)
Author:
chak@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ForeignFunctionInterface

    v12 v13  
    6565== Topics that need discussion for the integration into Haskell' == 
    6666 
    67  
    68 === `unsafePerformIO` === 
    69  
    70 Some have expressed the opinion that the inclusion of `unsafePerformIO` sends the wrong signal.  They aregue that although it is true that by giving inaccurate `foreign import`s one can define `unsafePerformIO`, but that doesn't mean it should be standard.  Moreover, as the stated purpose of `unsafePerformIO` in the FFI (hiding marshalling and unmarshalling for otherwise pure functions) can be achieved with a `runST`-like device if the language has [wiki:Rank2Types] or [wiki:RankNTypes]. 
    71  
    72  Personally, I don't see the issue.  We are including arbitrary C code.  For this to be safe, there are additional proof obligations.  The function `unsafePerformIO` is the same - for it to be safe, additional proof obligations have to be met.  Concerning a `runST`-like device, if the idea is to limit the scope of effects that are permitted by putting it into another monad and using a different interface, then this will at least complicate the API quite considerably.  Currently, marshalling is performed by functions that read and write arbitrary memory locations.  The FFI needs these functions anyway; hence, any other marshalling would need to add functions in addition to the existing ones.  Secondly, marshalling is somewhat unpredictable in that different C libraries require different marshalling.  Providing an interface with limited effects that captures all possible situations seems tricky, but if anybody has a concrete proposal, let's see it. 
    73  
    74   -- ManuelChakravarty 
    75  
    7667=== Include files === 
    7768