foreign export dynamic is a shortcut for importing an automatically generated nontrivial C function, with argument type not conforming to regular imports, which could not be written by hand.
I don't get it. How do you use a function with a type like: (Int -> IO Int) -> Addr to import a C function? The closest I can get is to use foreign label to get an Addr (or FunPtr if preferred) but now I'm stuck. What's up?
So it's actually an *import*! It could be spelled as import with a magical name - again all parameters are in the type.
But it is also used for exporting so the name doesn't seem that inappropriate. Unless you're arguing that, since it brings a name into scope it can be thought of as a kind of import??? (But I don't think you are saying that.) -- Alastair Reid reid@cs.utah.edu http://www.cs.utah.edu/~reid/
Sun, 6 May 2001 11:29:18 -0600 (MDT), Alastair Reid <reid@cs.utah.edu> pisze:
foreign export dynamic is a shortcut for importing an automatically generated nontrivial C function, with argument type not conforming to regular imports, which could not be written by hand.
I don't get it. How do you use a function with a type like:
(Int -> IO Int) -> Addr
to import a C function?
*This* is an imported function. Well, if I wanted to make it by hand, I would have to make a StablePtr before, because I can't pass (Int -> IO Int) to a foreign function directly. In other words foreign export dynamic exp :: (Int -> IO Int) -> IO Addr is equivalent to exp :: (Int -> IO Int) -> Addr exp f = exp' =<< newStablePtr f foreign import exp' :: StablePtr (Int -> IO Int) -> IO Addr -- exp' generated by the Haskell compiler.
Unless you're arguing that, since it brings a name into scope it can be thought of as a kind of import??? (But I don't think you are saying that.)
I am! -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTÊPCZA QRCZAK
participants (2)
-
Alastair Reid -
Marcin 'Qrczak' Kowalczyk