There are some issues with this kind of approach though, especially in a multi-platform environment. Mainly, it doesn't rely on a C compiler or any of the header files which is great if need to install it on a system for which you don't have a C compiler or header files but it also means you'll end up replicating the header files in the FFI code. And structures and function arguments tend to differ over different operating systems.
A simple example of this problem that I've ran into when using the CFFI system: the values of the RTLD_* constants (used as the MODE argument to dlopen) are different for at least Linux & BSD, but if you don't know that, the code will probably run but not do what you want on one of the systems. The suggested way to work around that is to parse the header files yourself - that is obviously not a very good way to go about things.
On the other hand, XS is really pretty good, as portable as C is (which is exactly the right amount of portable) and the only requirement is that you've got a decent C compiler + header files available. With strawberry perl, that should mean it's free for every major OS that perl runs on. Yes it's a bit more complicated, but not really that much. Get the book if you want to good introduction.
In reply to Re: platform agnostic foreign function interface, necessary?, missing?
by Joost
in thread platform agnostic foreign function interface, necessary?, missing?
by jettero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |