Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

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!

Replies are listed 'Best First'.
Re: Usable way of adding this feature to my module?
by toolic (Bishop) on Sep 04, 2013 at 00:55 UTC
      Whoops, thanks. Updated the link in the main post.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1052199]
Approved by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2018-02-19 04:28 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (258 votes). Check out past polls.