Two questions

D. Tweed tweed at
Tue Aug 28 09:02:50 EDT 2001

Hi, could anyone help me with some answers and/or some recommendations
about what to read (hopefully at a higher level than the source code :-) )
to get the answers to the following questions (I've read the current ffi &
hdirect documentation & examples and ffi-list archives but couldn't find
anything to answer these questions):

(1) The hdirect documentation appears to say that anything other than a
primitive type can only be returned as an abstract datatype. If this is
correct, is there any common way people have come up with to tackle
returns of datatypes (primarily lists) to some sort of datastructure that 
can be examined directly in C (well, C++)?

(2) Regarding calling C++ from Haskell, is it correct that all functions
being called have to be `extern C' because of C++-name-mangling? Other
than being inelegant, is there anything to prevent me trying to hack on a
stage in the foreign code interface stuff that compares the output of `nm'
and `nm --demangle' to do automatic conversion into mangled-names when
there is no overloading going on. (I ask this because it would minimise
the changes needed to the C++ source code to call C++ functions.)

To explain these questions, I'm interested in being able to use Haskell
more aggressively in developing prototype code (for visual analysis). At
present I write small independent Haskell scripts that test an algorithm
using synthetic test data; I'm looking at being able to call Haskell
prototype code directly from the main C++ application. (This would have
the advantage of being able to run the prototype code on real data
generated by the preceding C++ code.) Thus, unlike most of the FFI stuff I
see talked about in the documentation (which describes situations where
one of the sets of source code is essentially stable), the source code in
_both_ languages is extremely changeable.

My interest in `low programmer-overhead interfacing' is that my job is
currently `image processing' and nothing else; consequently if it takes
more time working with the interfacing tools than is saved by easier
prototyping in haskell I can't justify doing it.

Many thanks of any assistance anyone is able to provide,

___cheers,_dave________________________________________________________ |tweed's law:  however many computers
email: tweed at      |   you have, half your time is spent
work tel: (0117) 954-5250       |   waiting for compilations to finish.

More information about the FFI mailing list