On Fri, 13 Jan 2023 11:57:11 -0500
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
> We talked about the refaliasing
> feature, which remains broken on closures, a total showstopper.
An example of the breakage:
$ perl -E 'use feature qw(refaliasing);
my @arr;
sub boo { print "boo sees: @arr\n" }
\@arr = [1,2,3];
boo();
print "main sees: @arr\n";'
Aliasing via reference is experimental at -e line 1.
boo sees:
main sees: 1 2 3
This means that the main code vs. the function saw different things as
the actual @arr array. There's not a lot we can do about this. It
sortof comes down to the reasons why you can't `local` a `my` variable.
You shouldn't be able to do this here either but it was allowed. Oops.
> Paul
> wonders if we can reduce the scope of how the feature can be used.
> For example: what if you *must* also use declared_refs?
Whereas hypothetically if you do this it could be handled better:
my \@arr = [1, 2, 3];
sub boo { print "boo sees: @arr\n" }
...
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/
"Ricardo Signes" <perl.p5p@rjbs.manxome.org> wrote:
> We talked about the refaliasing
> feature, which remains broken on closures, a total showstopper.
An example of the breakage:
$ perl -E 'use feature qw(refaliasing);
my @arr;
sub boo { print "boo sees: @arr\n" }
\@arr = [1,2,3];
boo();
print "main sees: @arr\n";'
Aliasing via reference is experimental at -e line 1.
boo sees:
main sees: 1 2 3
This means that the main code vs. the function saw different things as
the actual @arr array. There's not a lot we can do about this. It
sortof comes down to the reasons why you can't `local` a `my` variable.
You shouldn't be able to do this here either but it was allowed. Oops.
> Paul
> wonders if we can reduce the scope of how the feature can be used.
> For example: what if you *must* also use declared_refs?
Whereas hypothetically if you do this it could be handled better:
my \@arr = [1, 2, 3];
sub boo { print "boo sees: @arr\n" }
...
--
Paul "LeoNerd" Evans
leonerd@leonerd.org.uk | https://metacpan.org/author/PEVANS
http://www.leonerd.org.uk/ | https://www.tindie.com/stores/leonerd/