doy/eval-closure — pull request #2 by tobyink (2013-07-23 16:24:16+00:00)
Title: Allow Eval::Closure to really close over variables.

Eval::Closure doesn't really close over variables; it just creates a copy of them. As a result, if you attempt to close over `my $foo = [1..3]`, your subroutine can happily do `push @$foo, 4`, which doesn't modify `$foo` itself, but modifies the data structure pointed to by `$foo`. But if your subroutine tries to do `$foo = [1..4]`, this change won't be seen outside the closure. A true closure created by `eval` would allow this, a la...

```perl
use strict;
use warnings;
use Data::Dumper;

my ($sub1, $sub2);

{
my $foo = [1..3];
$sub1 = eval q{ sub { $foo = [1..4] } };
$sub2 = eval q{ sub { return $foo } };
}

$sub1->();

print Dumper( $sub2->() );
```

Anyway, this pull request allows closures to work properly. It does break a couple of test cases, but I'd argue that those two are testing implementation details more than they are testing actual features. Those test cases could still be made to work via Data::Alias, but that module is currently broken on 5.18, and the amount of time it's taking to fix it makes me wary of using it even once it's working again.