Jan Dubois writes:
On Tue, 09 May 2006, John Peacock wrote:
And you are also wrong about it being "almost always wrong" since the
_only_ time it does the wrong thing is when a class overloads the
isa() method, which is far rarer than you want to acknowledge. Just
because /you/ want to use stub classes that overload isa() doesn't
bind all of the existing classes that correctly use this call.
Oh, I see, this is what it is about. In all the cases I use sv_derived_from()
it would be explicitly wrong to call an overloaded isa() in case it actually
lies and pretends to be derived from my base class if it isn't. The
sv_derived_from() code guards values that are stored as IVs in Perl data
structures, but are actually pointers to C structs. If the object is not
actually derived from the base class but just a mock object, then your
mock object is broken by calling my internal functions that expect a real
Just a note in passing as I catch up.
I have a lot of code where new is defined XS side and puts a C struct
or C++ object in a PV. I then use sv_derived_from ob the objects.
Derived classes can add methods (perhaps even by being proxies for
C++ classes derived from C++ class). But another class which
lies about its origins and hasn't created the object via the new
scheme will cause

static_cast<Myclass &>(SvPV(sv)).Method()

and we get SEGVs.


Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 19 of 20 | next ›
Discussion Overview
groupperl5-porters @
postedMay 10, '06 at 12:10a
activeJul 24, '06 at 5:50p



site design / logo © 2019 Grokbase