http://www.perlmonks.org?node_id=1158825


in reply to Re: Unifying namespaces of @name and $name to simplify dereferencing?
in thread Unifying namespaces of @name and $name to simplify dereferencing?

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.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^2: Unifying namespaces of @name and $name to simplify dereferencing? (experimental::refaliasing)(updated examples)
  • Select or Download Code