Re: Staying alive

1999-10-06 Thread Sven Panne
Michael Weber wrote: > [...] otherwise there would be a `marshalList' and `marshalListN' with > same type signature, which I also regarded as confusing. That was a problem with your approach, not mine... :-) > [...] But how else can you marshall an arbitrary length list? For > Int lists, ther

Re: Staying alive

1999-10-06 Thread Michael Weber
On Wed, Oct 06, 1999 at 12:04:03 +0200, Sven Panne wrote: > Michael Weber wrote: >>marshalListN :: Int -> [a] -> IO Addr > > I don't see a reason for the duplication of length information, e.g. > what should `marshalListN 1000 [1,2,3]' mean? And > `marshalListN 2 [1,2,3]' is equivalent to `ma

Re: Staying alive

1999-10-06 Thread Sven Panne
Michael Weber wrote: > Maybe it's worth to know how many objects a list has (without explicit > zeroElem), so I'd suggest to extend the class to: > >marshalList ::[a] -> IO Addr We agree here. >marshalListN :: Int -> [a] -> IO Addr I don't see a reason for the duplic

Re: Staying alive

1999-10-05 Thread Michael Weber
[My apologies: some day - I promise - I'll learn to choose the right mailing list... 8->] On Mon, Oct 04, 1999 at 13:45:43 +0200, Sven Panne wrote: [micro-marshalling] > I know Manuel's code already and the one H/Direct produces. Has anybody > else some FFI-related code and/or suggestions? This c

Re: Staying alive

1999-10-04 Thread Sven Panne
"Manuel M. T. Chakravarty" wrote: > I wouldn't call autoconf a hack :-) OK, MEGA-hack. :-) But it's m4 which is the real culprit... > [...] Anyway, such a class seems to be a nice way for expressing > the information about marshalable data types. The class is actually more about "micro"-mar

Re: Staying alive

1999-10-04 Thread Manuel M. T. Chakravarty
Sven Panne <[EMAIL PROTECTED]> wrote, > "Manuel M. T. Chakravarty" wrote: > > [...] So, how about providing functions that advance the `mem' > > pointer for you or even have `writeXXXOffAddr' return the > > next address after the datum just written? > > [...] This is, however, maybe not so helpfu

Re: Staying alive

1999-10-04 Thread Sven Panne
"Manuel M. T. Chakravarty" wrote: > [...] So, how about providing functions that advance the `mem' > pointer for you or even have `writeXXXOffAddr' return the > next address after the datum just written? > [...] This is, however, maybe not so helpful because of alignment > constraints that are har

Re: Staying alive

1999-10-03 Thread Manuel M. T. Chakravarty
Sven Panne <[EMAIL PROTECTED]> wrote, > Simon Marlow wrote: > > Manuel M. T. Chakravarty wrote: > > [...] we should really enforce a stack discipline and use a wrapper > > > function: > > > alloca :: Int -> (Addr -> IO a) -> IO a > > > > Nice idea. I'm not sure about the implementation though

Re: Staying alive

1999-09-23 Thread Sven Panne
Simon Marlow wrote: > Manuel M. T. Chakravarty wrote: > [...] we should really enforce a stack discipline and use a wrapper > > function: > > alloca :: Int -> (Addr -> IO a) -> IO a > > Nice idea. I'm not sure about the implementation though: did you > have in mind using C's malloc/free? Perh

RE: Staying alive

1999-09-23 Thread Simon Marlow
> I completely agree. Why not drop passing > (Mutable)ByteArrays to foreign functions altogether - if a > program wants to pass Haskell data to C land, the Right > Thing is to use a StablePtr. Agreed, if the call can re-enter the RTS. > Now there maybe efficiency > considerations when using t

RE: Staying alive

1999-09-22 Thread Manuel M. T. Chakravarty
"Sigbjorn Finne (Intl Vendor)" <[EMAIL PROTECTED]> wrote, > To clarify a little - while the arguments to a > 'foreign import' should at least live for the > duration of an invocation of a (safe) foreign > import, there's no guarantee that heap references > you pass out won't move. Hence, the sche

RE: Staying alive

1999-09-22 Thread Sigbjorn Finne (Intl Vendor)
To clarify a little - while the arguments to a 'foreign import' should at least live for the duration of an invocation of a (safe) foreign import, there's no guarantee that heap references you pass out won't move. Hence, the scheme outlined in the code of the original message isn't really going t

RE: Staying alive

1999-09-22 Thread Sigbjorn Finne (Intl Vendor)
It is currently not, but I think it should be. Will update the FFI spec to mention this issue. --sigbjorn > -Original Message- > From: Sven Panne [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, September 22, 1999 15:41 > To: GHC Users > Subject: Staying alive > > > In a recent discussio