[plt-scheme] C++ to Scheme

From: Thomas Chust (chust at web.de)
Date: Fri Mar 27 08:58:17 EDT 2009

2009-03-27 Paulo J. Matos <pocmatos at gmail.com>:
> [...]
> I have a C++ library that I need to use that includes some classes and
> some functions. What's the best way of using this library in
> PLT-Scheme. I see two ways:
> 1 - Creating a C wrapper by hand and using the FFI;
> 2 - Using SWIG;
> [...]

Hello,

I think the best choice depends on the complexity and size of the C++
API you want to bind, the time you want to spend creating the wrapper
and whether you want a wrapper for Scheme only or for multiple
scripting languages.

Using SWIG is relatively easy and saves you from a lot of tedious
tasks during the creation of a large wrapper, plus you can create
bindings for several languages with little effort once you have setup
your interface definitions correctly. However the code SWIG generates
is sometimes suboptimal.

Creating a binding by hand is not particularly complicated and can
produce nicer code than SWIG. However several of the convenient
features built into SWIG, like multiple language support or enabling
class inheritance hierarchies crossing the C++ - Scheme boundary
several times, require a lot of tedious coding effort when implemented
manually.

cu,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.