Allison Randal wrote:
It's true that you can't get a Python array and expect it to respond to all the same method calls as a Tcl array. But that Python array is just another variable type, that accepts keyed access and method calls. You treat it as a user-defined data type, and read the documentation to find out what method calls it accepts.
This is similar to how Inline::Java works. If you call a Java method you get back a Java object. It's up to you to translate that into a Perl object and you do that by reading the docs for that Java object and calling it's methods.
There is some magic to make Strings in Java be strings in Perl (same for numbers, etc). But it's not too deep. I would expect that this kind of shallow magic would be implemented in a Perl library. One each for the most popular language. And it would probably just consist of some methods that do casts.
While I don't expect every foreign data type to be immediately translated to a native type as soon as they touch the native code, I do expect it will be best practice to have any library in any language only return types native to its language.
Absolutely. Some of the talk of automagic object translation was getting me worried. If I'm calling a Java library it should return exactly what it's documentation says (a Java object). Then I as the application author should take the responsibility to make sure that code that uses my library should get exactly what it's expecting.
-- Michael Peters Plus Three, LP