ahey at iee.org
Tue Mar 23 03:01:13 EST 2004
I'd like to second Svens second seconding of my request. In my
original post saying that "you often need the length" rather
understates the case I think. Occasions where you don't need
the length seem to be quite rare (for me at least).
Also, this function may enable more space efficient code by
implementing some kind of lazy marshalling scheme, whereby
the memory allocated to the array was extended as required
as list evaluation proceeded. Dunno if that's technically
feasible in the rts of various Haskell implementations though.
But if it is, it won't save any memory with things as they
are because we need to hang on to the entire list in order to
calculate it's length :-(
On Tuesday 23 Mar 2004 12:51 am, Manuel M T Chakravarty wrote:
> On Tue, 2004-03-23 at 05:55, Sven Panne wrote:
> > Once upon a time, I wrote:
> > > Adrian Hey wrote:
> > >> [...] I think..
> > >>
> > >> withArrayLength :: Storable a => [a] -> (Ptr a -> Int -> IO b) -> IO
> > >> b
> > >>
> > >> would be useful because you often need the length in a foreign
> > >> function
> > >
> > > I would support that, similar situations happened a few times in my
> > > OpenGL/GLUT stuff.
> > >
> > >> and I guess withArray must pre-calculate the length before allocating
> > >> storage in any case [...]
> > >
> > > Yep.
> > There has been no other response yet, so I'd like to raise this issue
> > again. If we decide to add this to the module, it should be documented in
> > the FFI addendum as well, BTW. Any opionions?
> I think we need to decide how the further development of the FFI will
> proceed. Given that Version 1.0 of the Addendum is frozen, I am not in
> favour of changing the Addendum anytime soon and certainly not for small
> matters, such as a convenience function.
> We might want to accumulate extra useful functions in the implementation
> in an *extra* module and once there is enough interesting functionality
> in there, we can start talking about Version 1.1 of the Addendum.
> Does this sound like a sensible approach?
> FFI mailing list
> FFI at haskell.org
More information about the FFI