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

[perl #128654] [EXPERIMENT] Declared references

Tony Cook via RT
May 15, 2019 06:07
[perl #128654] [EXPERIMENT] Declared references
Message ID:
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;


via perlbug:  queue: perl5 status: new Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About