Mon, 24 Jul 2000 22:19:36 +0100, Claus Reinke <[EMAIL PROTECTED]> pisze:
> I only had a quick look at QForeign.hs, so I'm not sure whether
> this will help (do you really need that odd chaining of conversion
> functions?
Values of out parameters contribute to the result returned. Parameters
may require freeing some memory after calling the function and
a convenient exception-safe memory allocation and freeing is
(Pointer -> IO a) -> IO a
As compared to separate malloc + free, it should theoretically allow
a more efficient allocator.
> and why do you pass what seem to be conversion functions as
> parameters, do they not follow from the types?),
Not always, e.g. char * may be in, out, or in/out parameter.
It will get hairy with Unicode.
But maybe the combination of original and marshalled type, together
with more explicit treatment of out parameters, would allow convenient
overloading. I must try, fortunately types are usually explicit.
> For instance, if the base case for callN wasn't IO a, the two instance
> declarations would overlap;
Ah, I was once doing such overloading of IO functions. I tried but
was not able to adapt it to "threaded" foreign calls.
> > Is it possible to have some clever classes with instances for tuples
> > that would make some kinds of operations definable for all tuples
> > at once?
>
> The problem with tuples is that each length of tuple comes as a separate
> piece of *syntax* in Haskell, not built in a compositional way from tuples
> of smaller length.
I meant: given the nature of tuples we have, to have clever classes
with instances defined separately for high enough number of tuples,
to use them for various purposes as the only place which has to be
defined for different tuples separately.
Maybe conversion to and from nested pairs would do. But then changing
the nature of tuples themselves would seem more appropriate. With
GHC's -funbox-strict-fields it should be only an advantage.
--
__("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/
\__/ GCS/M d- s+:-- a23 C+++$ UL++>++++$ P+++ L++>++++$ E-
^^ W++ N+++ o? K? w(---) O? M- V? PS-- PE++ Y? PGP+ t
QRCZAK 5? X- R tv-- b+>++ DI D- G+ e>++++ h! r--%>++ y-