develooper Front page | perl.perl5.porters | Postings from February 2016

[perl #127531] permit \escape on right hand side of my

Thread Previous
Ricardo SIGNES
February 13, 2016 03:03
[perl #127531] permit \escape on right hand side of my
Message ID:
# New Ticket Created by  Ricardo SIGNES 
# Please include the string:  [perl #127531]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is pretty useful:

  perl -Mexperimental=refaliasing \
       -E 'my $x = [1,2,3]; \my @y = $x; say for @y'

...but the question I keep hearing is "why is the backslash on the my and not
the variable?"

The answer is not weird.  It's pre-existing syntax to get a reference to a new
variable.  It's still confusing, though, because people expect to be able to

  my \@y = $x;

I even got this question from Larry.

We should allow that.  It would also be good to allow:

  my ($x, \@y, \%z) = @_;

...which means we should then allow:

  sub foo ($x, \@y, \%z) { ... }

I would use the *heck* out of that feature.


Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About