John Tobey wrote:
> The Perl 5 (and older) behavior may preclude some optimizations.

I can't think of any optimizations @_ assignment precludes.
If we don't analyze dataflow to figure out if a sub modifies its
args, then we just assume it will.

Is this just a style issue? Why would you allow it with a
prototyped function? The following is fully prototyped and
still hard to optimize without dataflow:

sub make_setter ($) {
  my $x = \$_[0];
  sub { $$x = $_[0] }
}

{
  my $x = 1;
  my $f = make_setter($x);
  print "x = $x\n";
  &$f(2);
  print "x = $x\n";
}

Or do you mean that only prototypes taking a reference are
allowed to modify their arguments? So make_setter becomes

sub make_setter (\$) {
  my($x) = @_;
  sub { $$x = $_[0] }
}

How would you do vararg subs that have in/out args?

- Ken

Reply via email to