Don Schwarz - 2003-09-07

Since BSFPerl runs the Perl code in a separate process (unlike JPL), a communication protocol was needed to communicate between the two processes.  Instead of coming up with a new protocol and implementing both a parser and a serializer in Java and Perl, I decided to reuse Perl's normal expression format.  This meant that I could use Perl's parser (eval) to parse Java -> Perl messages and Data::Dumper to create Perl -> Java messages.  I implemented a parser and a serializer in Java that parsed a subset of Perl syntax (mostly only what I knew Data::Dumper was capable of writing).

In many cases, this was convenient.  However, I think it's already starting to become a limiting factor.  For example, right now only scalars, lists, maps, and unblessed references are actually sent to Java.  All blessed objects are simply sent to Java as logical names, which Java can call methods on in the future.  I would like to implement a mechanism whereby certain Perl objects would be wrapped with a java.lang.reflect.Proxy when passed from Perl into Java, based on the package that they are blessed into.  However, this information is not currently passed into Java, and there is no easy way in the current protocol to pass it.

Any bright ideas?  Should I just create my own protocol and implement a separate parser/serializer in Perl?  I've already had to manipulate Data::Dumper to get it to do what I want.  Reimplementing it may not be that bad.