Shawn H Corey said:
> On 10-09-13 07:50 AM, Nadim Khemir wrote:
> > I'm curious, someone care to comment?
> 
> I'm surprised that a specialized variable like @_ is not optimized for
> shift.  All that is needed is to more the pointer to the next item in
> the array.  The space used by the previous first item need not be
> recovered right away; the entire array will be recovered when the sub
> finishes.  And this won't use more memory.  Simply because if you copy
> instead, the whole array stays around until the sub finishes anyway.

I don't know if this would have any implications as to the behavior of a 
snippet like the following (i don't know perl's internals to know if it would 
or not), but if it does it could break a lot of things.

sub foo {
  my $foo = shift;
  $foo = "bar"; }

would not doing a copy for shift like that cause it to act like

sub foo {$_[0] = "bar"} does?

Reply via email to