
On March 11, 2011 09:17:54 Maurício CA wrote:
I wonder: why, in Haskell and also in other languages like ML, FFI is done with C type and code as references? Since, ultimately, compiled code goes to, say, ELF files or (in Windows) DLLs, shouldn't foreign interfaces be consistent with those?
Having an ELF file, a function name, and knowledge about the parameters for the function, is still not sufficient information to invoke it. I still need to know what calling convention is being used. That is, how to build the stack (which arguments to put on the stack and how to put them on), what to do with the registers (which arguments to put in them, which ones I can expect to be saved, any ones that are expected to be global pointers), how to receive results back (registers, on the stack, through a pointer), and, if I am expected to cleanup the stack afterwards. http://en.wikipedia.org/wiki/X86_calling_conventions Cheers! -Tyson