On Thu, Jul 31, 2014 at 12:26 PM, Nick Wellnhofer <[email protected]> wrote:
> OTOH, do we have to expose To_Host at all? It doesn't make sense to call
> To_Host from a host language since it will simply return the same object.
> And overriding it in the host language would result in a endless recursive
> call.
It would be great if we could replace To_Host() with an ordinary subroutine
and remove it as a method from Obj.
Here's the implementation in the Perl bindings for Obj, which would be serve
as the basis of the new subroutine:
http://s.apache.org/hE8
There are four custom implementations of To_Host().
Clownfish::Class and Clownfish::LockFreeRegistry need to set a flag to enable
sharing across Perl ithreads:
http://s.apache.org/Yqf
http://s.apache.org/p4L
(Hmm, it occurs to me that other global classes such as Clownfish::Method may
also need SvSHARE enabled. Also, using non-threadsafe classes such as String
and VArray within Class and Method is probably a bug.)
Clownfish::Err needs to set a flag to enable stringification overloading:
http://s.apache.org/ve
Lucy::Document::Doc needs to set a flag to enable hashref overloading:
http://s.apache.org/rH
The problem is that these flags are set on the *outer* RV (in at least some
versions of Perl), while Clownfish only keeps a copy of the inner object SV.
We could evaluate a return to caching the RV in Clownfish objects rather than
the inner object SV -- to_host() would then be implemented with
`newSVsv(obj->ref.host_obj)` rather than `newRV_inc(obj->ref.host_obj)`. This
would allow Class, LockFreeRegistry, Err and Doc to get at an outer RV and set
those flags during object construction, which would be propagated via newSVsv.
Marvin Humphrey