Which shows why you should return undef;
good point, yes that is a case when it would be use.
have you heard of 'cmpthese' -- much better if you want to post your premature nano-optimization results
yes I have, I just like the otherway more. Maybe one day I'll prefer the cmpthese() style.
I also know that the benchmarks are, in pure real world terms, complete bullshit - but I wanted to know what the speed difference between return; and return() was, with no other considerations. That was the only reason for benchmarking them.
The point was , if they bith give the same result in any context, when would you chose one over the other, though I agree it was misleading to say one was twice as fast - it could indicate I thought that was reason enough.
How can you pass up the 10-times faster version that does return 0
Easy, because in list context, it does not indicate failure - therefore in most cases, it is not what you want.
Pick between return (); vs. return; based on something other than speed.
I think that was my point - chose return() if it make your code clearer, otherwise always use return;
+++++++++++++++++
#!/usr/bin/perl
use warnings;use strict;use brain;
In reply to Re: Re: Functions that return nothing, nada, failure... (depends)
by leriksen
in thread Functions that return nothing, nada, failure...
by leriksen
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |