[Mono-list] SWIG, C++, templates and generics.

fevans fevans at harris.com
Fri Jan 16 11:19:18 EST 2009


I posted a message similar to this in the SWIG forum, so I suppose I'm guilty
of cross-posting.

I think mono would benefit, more than any other stack, from an investment in
SWIG or some similar technology.  http://www.swig.org

For better or worse Linux is pretty much a C++ domain.  There are some
aspiring stacks out there, but thus far none have gained much traction. The
Mono stack is gaining adoption simply because despite all the FUD Mono
simply works, period.

Hence the need for C++ interoperability. For those not familiar with SWIG,
here's a brief introduction:


SWIG  is a partial C/C++ compiler which takes C/C++ header files and
generates two outputs:
1. A C++ wrapper source file to include in your library (mylib_wrap.cc), as
well as C# files which will invoke the C++ library.  Its simple and for the
most works incredibly well.

There are however some limitations. It fully supports C, and somewhat
supports C++. In the domain of C++, templates are supported but its a
struggle. 

Now, the thing to keep in mind is that SWIG is designed to generate bindings
for multiple languages. Java, python, csharp, perl, and many more. As such
its architecture is somewhat encumbered by the fact that not all target
languages support the same constructs.

It seems to me the mapping of C++ templates to c# generics holds some
exciting possibilities.  I would think that the SWIG %template directive, or
some derivative of it could be used to push template instantiation further
into the runtime domain (away from compile time). 

Unfortunately, making this happen is well beyond my abilities. So at this
point I'm simply throwing the idea out for discussion.

-- 
View this message in context: http://www.nabble.com/SWIG%2C-C%2B%2B%2C-templates-and-generics.-tp21502889p21502889.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list