Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Functional Programming & method rewriting

by revdiablo (Prior)
on Oct 28, 2004 at 23:59 UTC ( [id://403553]=note: print w/replies, xml ) Need Help??


in reply to Functional Programming & method rewriting

my ($just_once,$and_later) = @_;

Why is it called $just_once if it executes every time?

Replies are listed 'Best First'.
Re^2: Functional Programming & method rewriting
by SpanishInquisition (Pilgrim) on Oct 29, 2004 at 00:18 UTC
    If you use it more than once, it whines and complains :) just_once does it keep the original form before it no longer works as advertised.

    I used to have it running warn() for the second function.

      If you use it more than once, it whines and complains ... I used to have it running warn() for the second function.

      Oh, I see. If you use the sub more than once, you get a custom complaint, which is defined by the second coderef.

      That seems a bit odd to me. I would probably make it only execute the first one once, and then have a standard warning thereafter. If it was necessary to have a custom message, I'd pass it in as a string argument, not another coderef. But perhaps your approach makes more sense for what you're doing.

      Or maybe you're just doing this to have fun with closures, in which case I'm putting entirely too much thought into the whole thing. :-)

      A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://403553]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2024-04-20 15:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found