develooper Front page | perl.perl5.porters | Postings from May 2019

[perl #128654] [EXPERIMENT] Declared references

From:
Tony Cook via RT
Date:
May 15, 2019 06:07
Subject:
[perl #128654] [EXPERIMENT] Declared references
Message ID:
rt-4.0.24-4333-1557900466-268.128654-15-0@perl.org
On Sun, 17 Jul 2016 11:26:25 -0700, sprout wrote:
> The declared_refs feature, which is about to be merged into blead,
> gives Perl 5.26.0 experimental support for declaring a reference to a
> variable:
> 
> my \$x; # equivalent to \my $x
> 
> It is intended mainly for use in conjunction with refaliasing:
> 
> my \$x = \$y;

The documentation:

Beginning in v5.26.0, the referencing operator can come after C<my>,
C<state>, C<our>, or C<local>.  This syntax must be enabled with C<use
feature 'declared_refs'>.  It is experimental, and will warn by default
unless C<no warnings 'experimental::refaliasing'> is in effect.

implies you can do:

  local \&foo = \&bar;

which you can't.

Of course, the above is equivalent to:

  local *foo = \&bar;

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=128654



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About