On Mon, Mar 17, 2003 at 01:20:44PM -0800, Brian Ingerson wrote: > Inline binds to libraries just fine. As you say, it does not generate an > interface from a header file, but I'm just not convinced that's a good > idea. I've always said that good C interfaces do not make good Perl > interfaces. I'm open to discussion with some actual use case examples > though. > > And BTW, I've always discouraged dumping a ton of C code into your Perl. > Create a library, definitely. And write only your interface code inline. > > FWIW, I'm actually using Inline *right now* to bind to a third party C > library. I definitely know I wouldn't want to see the entire header file > exposed to Perl. What a mess. I just need a couple interface functions, > and it's worth my time to hand tune them.
Sorry that this isn't "use case examples" as requested. I also think that C interfaces (good or otherwise) do not make good Perl interfaces. But perl makes a much faster prototyping language than C. I've not had to wrap an interface for perl since I've been thinking about this approach so I don't know how well it would work. But it's pretty much what Martin Brech was advocating as what he should have done in his YAPC::EU 2002 lightning talk "Lessons from a failed Perl-XS project" 1: Bulk autowrap as much of the original C interface as is practical quickly. This provides a really sucky perl interface (eg having to pass in pre-sized buffers), but it gets you away from C and into perl fast. 2: Wrap the auto-generated interface in more perl to provide a perl-like interface 3: Experiment with tweaking this interface until it feels right 4: Write the proper interface in Inline (or XS), and throw away the prototype. At stage 4 I wouldn't want Inline to wrap a header file, but at stage 1 I would. In some ways the steps 1-3 are what SWIG forces you to do anyway. Unless you have excellent SWIG-fu and know how to make it auto-generate exactly what you need. (Based on my limited use of SWIG some time ago) Nicholas Clark