Re: shift vs @_

2012-05-21 Thread David Christensen
On 05/21/2012 08:37 PM, Steve Bertrand wrote: On 2012-05-21 21:10, David Christensen wrote: Therefore, performance is first and clarity is second. Would you not agree that these are pretty extreme cases to be making such a wide-reaching decision on? Please trim your replies. No, I don't thi

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 21:10, David Christensen wrote: On 05/21/2012 12:40 PM, sono-io wrote: David, Are you saying that it would be faster to do: my $this_date = shift; my $output = shift; as opposed to: my ($this_date, $output) = @_; or am I not reading your assessment correctly? 1. Benchmarking on t

Re: shift vs @_

2012-05-21 Thread Rob Dixon
On 21/05/2012 21:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be better to

Re: shift vs @_

2012-05-21 Thread David Christensen
On 05/21/2012 12:40 PM, sono-io wrote: David, Are you saying that it would be faster to do: my $this_date = shift; my $output = shift; as opposed to: my ($this_date, $output) = @_; or am I not reading your assessment correctly? 1. Benchmarking on the target (production)

Re: shift vs @_

2012-05-21 Thread sono-io
> For one thing, there is the "Lies, Damned Lies and Benchmarks" factor I must have missed the e-mail that said "DOG PILE!!!". =;) Thanks to everyone for the explanations - all good food for thought. That's why I'm here. Marc -- To unsubscribe, e-mail: beginners-unsubscr...@pe

Re: shift vs @_

2012-05-21 Thread Lawrence Statton
On 05/21/2012 03:12 PM, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 14:51, Shawn H Corey wrote: On 12-05-21 04:32 PM, Steve Bertrand wrote: On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm cur

Re: shift vs @_

2012-05-21 Thread Shawn H Corey
On 12-05-21 04:32 PM, Steve Bertrand wrote: On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 14:12, sono...@fannullone.us wrote: Hi Paul, Please don't care about this until your code is running correctly but too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be

Re: shift vs @_

2012-05-21 Thread Steve Bertrand
On 2012-05-21 13:40, sono...@fannullone.us wrote: On May 20, 2012, at 10:07 PM, David Christensen wrote: I've updated function_arguments.pl with Benchmark, below. f_direct() is the fastest, f_shift() is in the middle (12% slower), and f_assign() is the slowest (37%). David, Are you

Re: shift vs @_

2012-05-21 Thread sono-io
Hi Paul, > Please don't care about this until your code is running correctly but > too slowly and profiling has determined that this is the bottleneck. I'm curious as to why you say this. If one way is faster than another, wouldn't it be better to do it that way, as long as it doesn't c

Re: shift vs @_

2012-05-21 Thread Paul Johnson
On Mon, May 21, 2012 at 12:40:15PM -0700, sono...@fannullone.us wrote: > On May 20, 2012, at 10:07 PM, David Christensen wrote: > > > I've updated function_arguments.pl with Benchmark, below. f_direct() is the > > fastest, f_shift() is in the middle (12% slower), and f_assign() is the > > slowes

Re: shift vs @_

2012-05-21 Thread sono-io
On May 20, 2012, at 10:07 PM, David Christensen wrote: > I've updated function_arguments.pl with Benchmark, below. f_direct() is the > fastest, f_shift() is in the middle (12% slower), and f_assign() is the > slowest (37%). David, Are you saying that it would be faster to do: my $this

Re: shift vs @_

2012-05-21 Thread Shawn H Corey
On 12-05-21 01:07 AM, David Christensen wrote: That's what I thought, until I started writing subroutines that modified @_ and stomped on the the caller's variables. Yes, that's what it does. That's why it's recommended to copy the values to my variables inside the subroutine. -- Just my 0.

Re: shift vs @_

2012-05-20 Thread David Christensen
On 05/20/2012 03:28 PM, Shawn H Corey wrote: On 12-05-20 06:15 PM, David Christensen wrote: If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this trivial. Once @_ has been shifted (latter style), I don't know an easy way to determine if zero or

Re: shift vs @_

2012-05-20 Thread Shawn H Corey
On 12-05-20 06:15 PM, David Christensen wrote: If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this trivial. Once @_ has been shifted (latter style), I don't know an easy way to determine if zero or one argument was passed (stack crawling?).

Re: shift vs @_

2012-05-20 Thread David Christensen
On 05/20/2012 08:09 AM, sono-io wrote: Are there any differences between these two idioms if only one or zero arguments are passed to them? my ($mode) = @_; my $mode = shift; If your subroutine needs to know how many arguments were passed, the former style (assignment) makes this tri

Re: shift vs @_

2012-05-20 Thread Rob Dixon
On 20/05/2012 16:16, John SJ Anderson wrote: On Sunday, May 20, 2012 at 11:09 AM, sono...@fannullone.us wrote: Are there any differences between these two idioms if only one or zero arguments are passed to them? my ($mode) = @_; my $mode = shift; If so, why would you chose one over the other

Re: shift vs @_

2012-05-20 Thread John SJ Anderson
On Sunday, May 20, 2012 at 11:09 AM, sono...@fannullone.us wrote: > Are there any differences between these two idioms if only one or zero > arguments are passed to them? > > my ($mode) = @_; > > my $mode = shift; > > If so, why would you chose one over the other? > > It seems to me that they