in reply to Re^4: Play Template
in thread Play Template
If all you saw was the "fistfight", you missed the important bits.
But if that and the other existing threads aren't sufficient to convince you that offering Readonly to novices as a template is not a good idea, then perhaps avoiding a 40x performance penalty will?:
#! perl -slw use strict; use Benchmark qw[ cmpthese ]; use constant { TRUE => 1, FALSE => 0, VALUE => 12345, }; use Readonly; Readonly::Scalar my $true => 1; Readonly::Scalar my $false => 0; Readonly::Scalar my $value => 12345; sub usingConstant { for( 1 .. 1e6 ) { if( TRUE ) { my $sum = VALUE * VALUE; } elsif( FALSE ) { ;## Never called } } } sub usingReadonly { for( 1 .. 1e6 ) { if( $true ) { my $sum = $value * $value; } elsif( $false ) { ;## Never called } } } cmpthese -1, { const => sub{ usingConstant() }, Readonly => sub{ usingReadonly() }, }; __END__ c:\test>ROvCONST.pl s/iter Readonly const Readonly 5.66 -- -98% const 0.141 3931% --
|
|---|