Skip Menu |
 

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Storable CPAN distribution.

Report information
The Basics
Id: 25093
Status: open
Priority: 0/
Queue: Storable

People
Owner: Nobody in particular
Requestors: MARKOV [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.15
Fixed in: (no value)



Subject: Closures loose their values
Download (untitled) / with headers
text/plain 393b
The attached script demonstrates how closures loose their captured parameters. I would really like to have this feature for XML::Compile, where I transform XML Schema's into trees of nested closures. Now, they have to be rebuild each program run. I think this is "severity Important" because the man-page does not warn for this limitation. Fixing it probably should end-up in the wishlist.
Subject: closure.pl
Download closure.pl
text/x-perl 369b
#!/usr/bin/perl use warnings; use strict; use Storable qw/freeze thaw/; { no warnings 'once'; $Storable::Deparse = 1; $Storable::Eval = 1; } my $y = {data => 13}; { my $x = 42; $y->{code} = sub {$x}; } print "Before: $y->{data} ", $y->{code}->(), "\n"; my $cold = freeze $y; my $warm = thaw $cold; print "Warmed: $warm->{data} ",$warm->{code}->(), "\n";
Download (untitled) / with headers
text/plain 894b
On Fri Feb 23 05:43:39 2007, MARKOV wrote: Show quoted text
> The attached script demonstrates how closures loose their captured > parameters. I would really like to have this feature for XML::Compile, > where I transform XML Schema's into trees of nested closures. Now, they > have to be rebuild each program run. > > I think this is "severity Important" because the man-page does not > warn for this limitation. Fixing it probably should end-up in the
wishlist. This feature is really beyond the scope of Storable. Storing the "values" for a closure in fact means storing the state of the perl interpreter. The complexity of this can be seen by imagining restoring two stored closures from different perl instances. While the Storable pod doesn't specifically mention closures (which it probably should), the 'CODE REFERENCES' section should give enough clues. Caveat: I am not the Storable maintainer.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.