JSPL::Visitor - Perl things visiting JavaScript
As described in "Round trip integrity" in JSPL all perl things that you pass by reference to JavaScript land conserve their identity, no matter how much they have travelled between both interpreters. Thats what you expect.
Upon entering JavaScript land they will become JavaScript objects, and as such they can be extended.
For example, your ARRAYs visiting JavaScript, as PerlArray instances, can be extended with some new non-numeric properties, and your perl subroutines, PerlSub instances, can get a 'prototype' property in its way to become constructors. That is the way JavaScript works.
PerlArray
PerlSub
Sometimes you need to break the transparency abstraction to known from perl land how your perl thing is being used on JavaScript.
When you call "jsvisitor" in JSPL::Context passing to it some reference that is visiting JavaScript you will get a JSPL::Visitor instance.
JSPL::Visitor
That objects allows you to inspect the perl value's wrapper object being used in JavaScript land.
JSPL::Visitor instances inherits from JSPL::Object. See that page for details.
In addition, JSPL::Visitor object have the following:
Returns TRUE if the instance is still valid, FALSE otherwise.
A perl thing visiting JavaScript becomes a visitor when it enters JavaScript for the first time, but looses its visitor status as soon as JavaScript garbage collects it. That is, when the thing's wrapper object isn't referenced in a property anymore.
Perl values that you bind become a visitor as long as they are binded, but perl values that you pass as arguments for JavaScript functions calls are visitors only for the duration of the call, unless the function stores the reference somewhere.
bind
JSPL::Visitor objects don't modify in any way the life cycle of the object nor the life cycle of the perl thing. if you hold a JSPL::Visitor for a long time, the object can be garbage collected in JavaScript, invalidating the JSPL::Visitor instance.
You should use only lexical variables in a well defined scope for JSPL::Visitor instances.
And unless you are playing "Alice in Wonderland", never pass to JavaScript a JSPL::Visitor. JSPL won't protect you for doing nasty things.
To install JSPL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm JSPL
CPAN shell
perl -MCPAN -e shell install JSPL
For more information on module installation, please visit the detailed CPAN module installation guide.