Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Usable way of adding this feature to my module?

by Hugmeir (Sexton)
on Sep 04, 2013 at 00:39 UTC ( #1052199=perlquestion: print w/ replies, xml ) Need Help??
Hugmeir has asked for the wisdom of the Perl Monks concerning the following question:

Bugger, that title is horrendous.

I have a module on CPAN, Params::Lazy. I want to add a new feature as part of a bugfix, namely, that delayed arguments can see the delayer's original @_. Basically, it allows you to do this:

use Params::Lazy delay => q(^); sub delay { my ($delayed) = @_; say "delayed shift: ", force $delayed } sub calls_delay { delay shift @_; } calls_delay("original arg");

Which in the original version would've printed "delayed shift: SCALAR(whatever)", since the first argument of delay() would've been a scalar ref, and "delayed shift: original arg" in the new version.

However, this entrails some possible hits to performance, particularly when combined with threads, and it's entirely possible that people may not want the original @_ for some reason. So I'm left wondering how to provide both functionalities. I was thinking perhaps something like:

use Params::Lazy caller_args => { 'foo' => q(^^) };

But it occurs to me that "using the original @_" might be the most common case, so perhaps enable it by default and have people explicitly request the old version somehow. Or perhaps something like this?

no Params::Lazy 'caller_args';

I'm honestly pretty stumped, so any input is welcome!

Comment on Usable way of adding this feature to my module?
Select or Download Code
Re: Usable way of adding this feature to my module?
by toolic (Chancellor) on Sep 04, 2013 at 00:55 UTC
      Whoops, thanks. Updated the link in the main post.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1052199]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2014-09-02 05:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (20 votes), past polls