CC: | bug-Storable [...] rt.cpan.org, perl5-porters [...] perl.org |
Subject: | Re: Storable - Feature-request - alternate freeze/thaw hooks |
Date: | Sun, 30 May 2010 19:23:54 +0300 |
To: | tabris <tabris [...] tabris.net> |
From: | Yuval Kogman <nothingmuch [...] woobling.org> |
That would break circular references, which might not be a concern for
GMP ints but is required for other things.
However, ince the typemap specifies:
OUTPUT
MPZ
sv_setref_pv($arg, \"Math::BigInt::GMP\", INT2PTR(void*, $var));
You can probably just get away with
sub STORABLE_thaw {
my ( $self ) = @_;
my $new = ... thaw a new instance ...;
bless $new, "Something::Else"; # avoid any destructors
$$self = $$new; # simply steal the pointer
}
but it would probably be better to refactor the M::B::GMP code to
allow doing this sort of thing without violating encapsulation.