Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Perl-Critic CPAN distribution.

Report information
The Basics
Id:
28840
Status:
rejected
Priority:
Low/Low
Queue:

People
Owner:
Nobody in particular
Requestors:
joey [...] kitenet.net
Cc:
AdminCc:

BugTracker
Severity:
Normal
Broken in:
(no value)
Fixed in:
(no value)



Subject: ProhibitStringyEval misses reasons to use stringy eval when loading a module
ProhibitStringyEval doesn't take into account that eval q{use Foo}; defers the use until the eval runs, which is often a useful optimisation. While eval {use Foo}; does not defer the use at all.
On Tue Aug 14 22:21:36 2007, JOEY wrote:
Show quoted text
> ProhibitStringyEval doesn't take into account that eval q{use Foo}; > defers the use until the eval runs, which is often a useful optimisation. > While eval {use Foo}; does not defer the use at all.
But eval q{use Foo}; is just a slow version of eval {require Foo;Foo->import}; The latter has all of the runtime deferral of the former and adds compile-time syntax checking and avoids a runtime re-entrance into the compiler.
Subject: Re: [rt.cpan.org #28840] ProhibitStringyEval misses reasons to use stringy eval when loading a module
Date: Wed, 15 Aug 2007 03:21:15 -0400
To: Chris Dolan via RT <bug-Perl-Critic@rt.cpan.org>
From: Joey Hess <joey@kitenet.net>
Chris Dolan via RT wrote:
Show quoted text
> But eval q{use Foo}; is just a slow version of eval {require > Foo;Foo->import}; > > The latter has all of the runtime deferral of the former and adds > compile-time syntax checking and avoids a runtime re-entrance into the > compiler.
That's a good point. Benchmark[1] says it's about 5x faster that way. Of course, we're talking 16000 iterations per second for the slow one, so the chances of this mattering are zero. I think I'll stick with the more readable version even if it is marginally slower. -- see shy jo joey@kodama:~>perl -e 'use Benchmark; use List::Util; timethese(100000, {stringy_eval => sub { eval q{use List::Util } } , optimised => sub { eval { require List::Util; List::Util->import } } })' Benchmark: timing 100000 iterations of optimised, stringy_eval... optimised: 1 wallclock secs ( 1.53 usr + 0.00 sys = 1.53 CPU) @ 65359.48/s (n=100000) stringy_eval: 5 wallclock secs ( 6.11 usr + 0.00 sys = 6.11 CPU) @ 16366.61/s (n=100000)

Message body not shown because it is not plain text.

From: ELLIOTJS@cpan.org
Have you tried Perl::Critic::Policy::Lax::ProhibitStringyEval::ExceptForRequire?
Yes, I think the Lax:: version of the policy is what you want. If you install that distro, you can just disable the ProhibitStringyEval policy in your perlcriticrc and use the Lax:: one instead. I don't plan to change this policy in Perl::Critic so I'm going to mark it as "rejected".
Subject: Re: [rt.cpan.org #28840] ProhibitStringyEval misses reasons to use stringy eval when loading a module
Date: Thu, 20 Sep 2007 12:54:54 -0400
To: via RT <bug-Perl-Critic@rt.cpan.org>
From: Joey Hess <joey@kitenet.net>
via RT wrote:
Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=28840 > > > Have you tried Perl::Critic::Policy::Lax::ProhibitStringyEval::ExceptForRequire?
Wasn't aware of Perl::Critic::Policy::Lax but it looks like what I was after, thanks. -- see shy jo

Message body not shown because it is not plain text.



This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.