Re: FFI Help

2003-06-09 Thread Manuel M T Chakravarty
"Simon Peyton-Jones" <[EMAIL PROTECTED]> wrote, > Would it be worth mentioning or amplifying this point in the FFI spec, > or perhaps in an accompanying Appendix/Commentary of examples and FAQs? > Else someone else is going to trip over it sooner rather than later. Good point. I think this is ce

Re: new ForeignPtr without finalizers

2003-06-09 Thread Malcolm Wallace
Ashley Yakeley <[EMAIL PROTECTED]> writes: > OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that > doesn't have any finalizers? > > newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a) > newSimpleForeignPtr ptr = ?? Why would you want to? A ForeignPtr without any finalizers

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
On Monday 09 June 2003 4:59 am, Ashley Yakeley wrote: > OK, I just upgraded to GHC 6.0. How do I create a new ForeignPtr that > doesn't have any finalizers? > > newSimpleForeignPtr :: Ptr a -> IO (ForeignPtr a) > newSimpleForeignPtr ptr = ?? There is no direct way in the ffi. You could define

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
Ashley: > How do I create a new ForeignPtr that doesn't have any finalizers? Malcolm: > Why would you want to? addForeignPtrFinalizer lets you add them later. I'm guessing that Ashley is making heavy use of this ability. [What we have at the moment is the ability to attach a non-empty list of f

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Alastair Reid <[EMAIL PROTECTED]> wrote: > It looks like you're using an idiom we didn't think of when designing the > library. Can you explain what you're trying to do and whether you think we > shoud provide direct support for newSimpleForeignPtr (which I'd be

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Malcolm Wallace <[EMAIL PROTECTED]> wrote: > Why would you want to? > > A ForeignPtr without any finalizers is semantically just a Ptr, > plain and simple. I need a pointer type for which some values have finalizers, and some don't. -- Ashley Yakeley, Seattle

Re: new ForeignPtr without finalizers

2003-06-09 Thread Malcolm Wallace
Ashley Yakeley <[EMAIL PROTECTED]> writes: > Specifically I want a ForeignPtr of a null Ptr that has no finalizers. Ah, this makes sense. I wonder if we should add the following to the FFI spec module ForeignPtr? nullForeignPtr :: ForeignPtr a -- a null pointer with null finalizer Rega

Re: new ForeignPtr without finalizers

2003-06-09 Thread Axel Simon
On Mon, Jun 09, 2003 at 01:21:38PM +0100, Malcolm Wallace wrote: > Ashley Yakeley <[EMAIL PROTECTED]> writes: > > > Specifically I want a ForeignPtr of a null Ptr that has no finalizers. > > Ah, this makes sense. > I wonder if we should add the following to the FFI spec module ForeignPtr? > >

Re: new ForeignPtr without finalizers

2003-06-09 Thread Manuel M T Chakravarty
Alastair Reid <[EMAIL PROTECTED]> wrote, > Ashley: > > How do I create a new ForeignPtr that doesn't have any finalizers? > > Malcolm: > > Why would you want to? > > addForeignPtrFinalizer lets you add them later. > I'm guessing that Ashley is making heavy use of this ability. > > [What we have

Re: new ForeignPtr without finalizers

2003-06-09 Thread Alastair Reid
On Monday 09 June 2003 3:48 pm, Manuel M T Chakravarty wrote: > Andre proposed to allow `nullFunPtr' as a finalizer argument > to `newForeignPtr' to indicate the lack of a finalizer. > This seems quite C-ish, but has the advantage that it is > easy to parametrise functions that internally use > `ne

Re: new ForeignPtr without finalizers

2003-06-09 Thread Dean Herington
Alastair Reid wrote: > I'm not convinced that merging them into a single function is desirable, but, > if we wanted to, I think a better FPish solution is to use > > Maybe (FinalizerPtr a) As multiple finalizers are allowed, perhaps we should consider: newForeignPtr :: [FinalizerPtr a] -> Ptr

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 9

2003-06-09 Thread Ross Paterson
On Sun, Jun 08, 2003 at 09:06:07PM +1000, Manuel M T Chakravarty wrote: > Ross Paterson <[EMAIL PROTECTED]> wrote, > > On Wed, Jun 04, 2003 at 11:09:43PM +1000, Manuel M T Chakravarty wrote: > > > StablePtr are used to export references to Haskell values to > > > C, where they are treated as abstra

Re: new ForeignPtr without finalizers

2003-06-09 Thread Ashley Yakeley
In article <[EMAIL PROTECTED]>, Alastair Reid <[EMAIL PROTECTED]> wrote: > I'm not convinced that merging them into a single function is desirable, but, > if we wanted to, I think a better FPish solution is to use > > Maybe (FinalizerPtr a) I think the most FPish solution would be this:

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 9

2003-06-09 Thread Marcin 'Qrczak' Kowalczyk
Dnia wto 10. czerwca 2003 01:00, Ross Paterson napisaƂ: > I meant to say that you can't pass an HsDouble to a "polymorphic" C > function expecting (void *), You can pass a pointer to double. Imagine a hashtable implemented in C. It will most probably store void * as values. You can use it for an

Re: ANN: H98 FFI Addendum 1.0, Release Candidate 9

2003-06-09 Thread Manuel M T Chakravarty
Ross Paterson <[EMAIL PROTECTED]> wrote, > On Sun, Jun 08, 2003 at 09:06:07PM +1000, Manuel M T Chakravarty wrote: > > Ross Paterson <[EMAIL PROTECTED]> wrote, > > > On Wed, Jun 04, 2003 at 11:09:43PM +1000, Manuel M T Chakravarty wrote: > > > > StablePtr are used to export references to Haskell v

exercising the storage manager

2003-06-09 Thread Peter Gammie
g'day everyone, I'm getting segv's from a program using the FFI (ghc5.0x) on MacOS X only, i.e. not on Linux, my primary development platform. So... does anyone have any tips for showing up dodgy uses of the FFI wrt memory handling? What settings for GHC's garbage collector will create the most p