in reply to Re: Re: Introducing Data::Dump::Streamer
in thread Introducing Data::Dump::Streamer

Data::Dumper doesn't handle closures, in the sense that it makes no effort to provide a lexical environment that will match what the closures have. E.g. (untested):
sub make_incrementor { my $inc_by = shift; my $value; return sub { $value += $inc_by } } $by2 = make_incrementor(2); $by4 = make_incrementor(4); $by2->(); $by2->(); $by4->(); print Dumper [$by2, $by4];
This is a hard problem.

Replies are listed 'Best First'.
Re: Re: Re: Re: Introducing Data::Dump::Streamer
by demerphq (Chancellor) on Feb 26, 2004 at 16:40 UTC

    Well, this is actually a problem of B::Deparse and perl overall than it is Dumper or Streamer's fault. There is no way (that I no of, feel free to educate me :-) to know what vars _were_ in the lexical enviornment of the sub, nor to know that when the dump is evaled back whether the user has arranged for these vars to be available or not. IMO this is beyond the requirements of these modules. If you need to use them for serialization of subs then you should take care to manage such things yourself. Personally I only included it to make debugging easier. :-)


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi