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