Richard W.M. Jones wrote:
On Thu, Apr 18, 2013 at 01:14:33AM +0200, Björn Persson wrote:
> > Passing pointers to objects from one language to another is likely
> > *not* possible however.
> Ada imports and exports C pointers just fine, including pointers to
> functions and records.
I should have been clearer. I meant passing pointers between non-C
languages is likely not possible.
If you mean some kind of fat pointer, that the compiler implements as
more than just a memory address, then the one compiler would have to
know how the other compiler implements those pointers, and the source
code would need to contain an instruction to the compiler to use the
other compiler's convention. If both compilers are GCC this should be
possible. With compilers from different vendors the coordination could
be more of a problem.
It seems to me that it's not a matter of pointers so much as the
datatypes that the pointers point to. If a type can be represented in
both languages, then both objects of that type and pointers to objects
can be passed around and used in both languages, as long as at least
one of the compilers has appropriate interfacing features. If a type in
one language can't be represented in the other language, then objects
of that type can't be passed to the other language, and pointers can
only be handled as opaque handles to be kept and passed to callbacks.
If you mean purely high-level languages that don't even have pointers
on the source code level, then yes, handling pointers in those
languages could be problematic. Still, any language that can interface
with C and deal with C pointers can also share C pointers with any
other language that can interface with C.