[plt-scheme] External interface to C++ code on MacOSX

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Aug 9 08:56:10 EDT 2006

At Tue, 8 Aug 2006 00:24:48 -0400, Jim Witte wrote:
> Is it possible to have an external library have this  
> level of interaction with the Scheme environment?

Yes. The two approaches are to write glue code in C/C++ or to use `(lib
"foreign.ss")'. For the former, see "Inside PLT MzScheme" and the
examples in "plt/collects/mzscheme/examples". For the latter, start
with "PLT Foreign Interface Manual".

Usually, `(lib "foreign.ss")' is definitely the way to go. But `(lib
"foreign.ss")' can't talk directly to C++, because the C++ ABI is too
complex and unportable.

If it were me (and if I understand your task correctly), I'd generate a
C interface to the C++ classes, and then use `(lib "foreign.ss")' to
glue Scheme to the C interface.

Matthew



Posted on the users mailing list.