
There's more than one way to do things

Comment on


Exceptions should be "exceptional". That is, you shouldn't expect them to happen during normal functioning of the program. So lets see what the overhead of providing (unused) exception handling is:

use strict; use warnings; use Benchmark 'cmpthese'; cmpthese(-1, { 'eval' => \&eval_code, 'noeval' => \&no_eval_code, }); sub eval_code { my $x = 0; for (reverse 0..9) { eval { some_more_code ($_); }; if ($@) { error_sub(); } } } sub no_eval_code { for (reverse 0..9) { if ($_==0) { error_sub(); } else { some_more_code ($_); } } } sub some_more_code { } sub error_sub { }


Rate eval noeval eval 185563/s -- -7% noeval 198639/s 7% --

In words: the processing cost of an unexercised eval is essentially nothing.

DWIM is Perl's answer to Gödel

In reply to Re^2: Nested evals - are they evil? (sample benchmarks) by GrandFather

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (9)
    As of 2014-03-13 22:40 GMT
    Find Nodes?
      Voting Booth?

      Have you used a cryptocurrency?

      Results (290 votes), past polls