There is interest in importing functions from other languages so they are usable in Asymptote scripts.
See
http://sourceforge.net/forum/message.php?msg_id=4499156
For C++, this could be done by exposing some of the functionality of runtime.pl, but producing a shared library and some sort of asy "header" file. Implementing this shouldn't be too hard, but making it user friendly might be.
Logged In: YES
user_id=1882395
Originator: NO
One pressing question: How will internal structures (i.e. pairs, arrays, other asymptote functions) be exposed to the outside code?
Logged In: YES
user_id=1144470
Originator: YES
Asymptote structures will probably be exposed basically as they are in runtime.in (which I strongly suggest you take a peek at if you haven't yet).
For instance, pair is a C++ class defined in pair.h:
pair z;
real x=z.getx();
real y=z.gety();
Arrays are defined in array.h. Elements have to be cast to and from the item class when reading/writing the array. item is sort of like PyObject:
item i=4.0;
real four=get<real>(i);
size_t size=5;
array *a=new array(size);
for (size_t i=0; i<size; ++i)
(*a)[i]=3.14;
real sum=0.0;
for (size_t i=0; i<size; ++i)
sum+=read<real>(a,i) // or: get<real>((*a)[i])
Functions are a set of polymorphic classes derived from the abstract base class callable in callable.h. They are called by pushing arguments on the stack in left-to-right order, calling, and then popping the result:
callable *f= <something> ;
Stack->push(arg1);
Stack->push(arg2);
f->call(Stack);
real result=pop<real>(Stack);
Because of the extensive use of classes in the code, it would probably be prohibitively difficult to work with these structure using pure C. This would not prevent people from wrapping existing C libraries for use with Asymptote.
Also, these classes have been designed just for internal use, so-to-speak. They may need some cleaning up before exposing them via this API, but that is not neccessarily a bad thing. One thing is for sure, though. When using early versions of this interface, you are going to get your hands dirty.