Tue, 15 Aug 2000 01:55:17 -0700, Simon Marlow <[EMAIL PROTECTED]> pisze:
> Marcin's library has two key properties (if I understand correctly):
Yes. A third: relying on allocation in the style of
(pointer -> IO a) -> IO a.
for temporary values. It's exception safe and permits a more efficient
allocator in future (perhaps using the standard stack in GHC).
The new <http://qrczak.ids.net.pl/qforeign.tar.gz> is out
(half-baked and lacks docs). Major changes:
* Overloaded "obvious" marshalling of function argument and results,
with unbounded number of parameters (thanks to Claus Reinke).
Old framework with inString etc. removed.
* Charset conversion framework started. Implemented the default
locale-dependent multibyte encoding and UTF-8. The former is used
by conversions between Haskell String and C char[].
* glue-hsc: a preprocessor that inserts bits taken from C headers.
* Marshalling C structs stuff removed.
* Some C char[] support: allocation, conversions from/to String and
[CChar].
> Would it be possible to decouple this into a basic marshalling library
> without typed pointers, with Marcin's framework built on top?
The basic marshalling library would be either very small (Storable
class uses typed pointers), or duplicate the same things with
a different interface (like I currently use Foreign.Storable to
implement my Storable). Pointers are used everywhere.
Typed pointers are useful in the interface because allocation does
not have to pass sizeOf, nor a sample argument. Byte sizes are rare.
OTOH it should be easy to split into impl-dependent and
impl-independent parts, as long as they agree on basic types.
The current split into two modules does not reflect this exactly.
It's easier when CTypes and sized integers are available to use in
basic stuff. In future standard libraries should correctly translate
strings between Unicode and the system's encoding in I/O, filenames etc.
It would be a bit awkward without CTypes and the impl-independent part.
Non-standard library features used:
* Addr.
* sized integers, CTypes.
* StablePtr, ForeignObj, freeHaskellFunctionPtr
(only to reexport with typed pointers).
* The functionality of Foreign.Storable for types to be supported.
* Throwing IO errors other than UserError. This is _not_ using
GHC-specific exceptions throwable in pure code, but something every
Haskell implementation uses internally anyway to throw IO errors.
Only there is no Haskell98 interface to this. Currently it does not
fully translate errno yet (only uses strerror's message), but it will.
* Exception.bracket for protection againts memory leaks. It would be
IO.bracket in an implementation that does not support catchable
exceptions thrown in pure code.
* MVar in an unimportant convenience wrapper.
* IORef, unsafeInterleaveIO, ForeignObj in charset conversion (essential).
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/
^^ SYGNATURA ZASTĘPCZA
QRCZAK