On 24/11/2015 04:17, Marvin Humphrey wrote:
A binding for a method which might be overridden in a dynamic host and invoked
as a SUPER method must not use vtable dispatch.  This is because the vtable
for the host subclass will contain a callback stub which invokes the host
method... which invokes SUPER... which invokes the host method via the
callback stub... which invokes SUPER... which invokes the host method via the
callback stub... and eventually you get a stack overflow.

The reason that the XS bindings for Clone had all that hackery in them was
that I was trying to preserve CFC's autogeneration of bindings for Clone in
subclasses outside of the Clownfish core runtime, yet have e.g. the Perl sub
Clownfish::String::clone() return an actual Clownfish::String rather than a
Perl UTF-8 string SV.  The implementation had some bugs and I'm glad it's
getting an overhaul, but I don't think we've got this licked just yet.

Fortunately I think Clone is a corner case and our overall approach remains
sound and compatible with SUPER.  We just need to figure out how to override
the autogenerated bindings for Clone for a handful of classes where the CFC's
type mapping causes a host type to be returned rather than the Clownfish
object.

I was vaguely aware of this, but thanks for explaining it again. I think the best fix is to keep the autogenerated bindings for Clone, and add a separate method like `clone_raw` to the Obj Perl bindings that always returns a Clownfish object, like I did with Vec_Fetch and Hash_Fetch.

Nick

Reply via email to