[Haskell-cafe] compilation to C, not via-C

Alex Queiroz asandroq at gmail.com
Fri Apr 24 13:31:06 EDT 2009


On 4/24/09, Donn Cave <donn at avvanta.com> wrote:
> Quoth Alex Queiroz <asandroq at gmail.com>,
>  >      Actually some Scheme compilers have a "c-declare" form that lets
>  > you create C functions, which can be called from C, Haskell, Java,
>  > Ruby etc.
> That would be like what you get with Haskell FFI "export"?
>  When I do this with nhc98, I need a nhc98 "main", and I would expect
>  the same with GHC.  Part of the deal would be smuggling in and
>  initializing the Haskell runtime.  Also figuring out storage, if
>  returning any values from the exported Haskell function (as opposed
>  to poking them into address parameters.)  I can see how this would
>  not be suitable for a library.

     Incurring the risk of being too much off-topic, I'll just say
that I use the Gambit-C Scheme compiler to produce C code that I link
with my C driver code. I need to write the driver ("main" and friends)
in C because my software is compiled as a Windows service or POSIX
daemon, which requires special care. But of course you must link in
the Scheme runtime, with the garbage collector, Scheme data types etc.


More information about the Haskell-Cafe mailing list