Your right it's not consistent.
But IMHO consistency will most likely break legacy code.
I think that there should at least be a warning.
Since it's not always clear if a variable is an alias, this can cause very hard to detect errors in subs which are meant to modify call-by-reference parameters. (not to be confused with Perl references)
Did you check if there are already older bug-reports regarding this?
UPDATE:
DB<108> sub inc_a { $_[0]++; return }
DB<109> $x=1; inc_a($x); print $x
2
DB<110> inc_a(1)
Modification of a read-only value attempted at (eval 13)[/usr/share/pe
+rl/5.10/perl5db.pl:638] line 2.
but
DB<111> sub inc_b { my $r=\ $_[0]; $$r++; return }
DB<112> $x=1; inc_b($x); print $x
2
DB<113> inc_b(1)
DB<114>
When passing an aliasing variable instead of 1 it's the same problem. With inc_b non-aliasing vars will increment, but aliases will silently fail to increment. |