Oh thanks that's indeed interesting, Perl core finally allowing aliasing of lexicals! :)
... not sure if it solves the all issues yet...
But you know these new possibilities deserve a proper thread ...
update
hmm ... coupling is broken after assigning a new ref
use 5.22.0;
use feature qw/say refaliasing/;
no warnings "experimental::refaliasing";
\my @a = my $a = [666];
say "noref: $a[0], ref: $a->[0], list: @a";
$a = [42];
say "noref: $a[0], ref: $a->[0], list: @a";
-->
noref: 666, ref: 666, list: 666
noref: 666, ref: 42, list: 666
update
at least passing arrays to arrays is possible now
use 5.22.0;
use feature qw/say refaliasing/;
no warnings "experimental::refaliasing";
my @a = (666,42);
test (\@a,\@a);
sub test {
(\my @sub, my $ref) = @_;
say "noref: $sub[0], ref: $ref->[0], list: @sub";
}
-->
noref: 666, ref: 666, list: 666 42
well the syntax when passing more than one argument is not very elegant, see duplicated my ... but at least it's consistent.
|