# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #114946]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=114946 >


Well, I don't think that I'm doing anything stupid here, but it's always
a possibility.

Surely if function parameters are readonly *aliases* to the argument
passed to the function, then they should see modifications made to that
argument by other parts of the code. eg

$ cat ../test/aliases.pl
use v6;

my $global = "Perl Rules";

sub baz {
    $global ~~ s/Perl /Perl 6/;
}

sub foo ($bar) {
    say $bar;
    baz;
    say $bar;
    try {
        ++$bar;
    }
    say $!;
}

foo($global);

say "But at the end: $global";
$ ./perl6 ../test/aliases.pl 
Perl Rules
Perl Rules
Cannot assign to a readonly variable or a value
  in sub prefix:<++> at src/gen/CORE.setting:1350
  in sub foo at ../test/aliases.pl:14
  in block  at ../test/aliases.pl:19

But at the end: Perl 6 Rules


I would have expected the second line to be "Perl 6 Rules", because the
aliased value has been changed by the call to &baz().

$ ./perl6 -v
This is perl6 version 2012.07-270-g5e1b9a8 built on parrot 4.4.0 revision 
RELEASE_4_4_0


Yes, there is an ulterior motive to this bug report. I'm not confident that
read only aliases are actually an optimiser win. You mustn't assume that the
aliased value remains unchanged by any opaque action, such as a function
call, else you break correctness.

Nicholas Clark

Reply via email to