I agree with everything your say ;-) but I have a different slant on many of your points.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.