" via RT" <bug-Tangram@rt.cpan.org> writes:
Show quoted text> Perl 5.8.0 has a pretty serious bug w.r.t. to tied objects, which makes
> Tangram pretty much incompatible with that version.
Note that the field is untied only to improve performance. If you
detect 5.8.0, just leave the field tied, e.g.:
package Tangram::RefOnDemand;
sub TIESCALAR
{
my $pkg = shift;
return bless [ @_ ], $pkg;
}
sub FETCH
{
my $self = shift;
my ($storage, $id, $member, $refid) = @$self;
my $obj = $storage->{objects}{$id};
return @$self == 5 ? $self->[4] : $self->[4] = $storage->load($refid);
}
sub STORE
{
my ($self, $val) = @_;
my ($storage, $id, $member, $refid) = @$self;
my $obj = $storage->{objects}{$id};
return $self->[4] = $val;
}
I have not tried (nor even compiled) that code, and it's 5.8.0 only;
at Ref.pm load time you'll have to check Perl's version number and
stick the appropriate sub in *FETCH and *STORE.
Since weakrefs are available in 5.8.0, it's also probably more
appropriate to store a weakref to $obj rather than going each time
through $storage to find the object.
--
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com