Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re^6: closure clarity, please

by JadeNB (Chaplain)
on Dec 07, 2009 at 16:39 UTC ( #811543=note: print w/replies, xml ) Need Help??

in reply to Re^5: closure clarity, please
in thread closure clarity, please

Here's another way of demonstrating the effect in your sample code, with hopefully a bit less “magic gluing”:
sub g { my ( $a ) = @_; sub f { $a }; return sub { $a = $_[0] }; } push my @setters, g("Hi\n"), g("Bye\n"); print f; # => Hi $setters[0]("Bye\n"); print f; # => Bye $setters[1]("Hi\n"); print f; # => Bye (still)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://811543]
[Corion]: On the upside, I spend a lot of time thinking this weekend about how to actually implement rate limiting for futures, and if things work out, maybe even loading a configuration from an external file makes sense
[Corion]: I've also found some interesting invariants that I have to think/write about more. A simple rate limiter will never change the order of the input, while a limiter that allows for parallel execution will change the order. But my API currently allows for bo
[Corion]: ... for both, and I'm not sure if I want to add the cruft from the parallel API (a token that you need to hold on to while you hold the lock) to the rate limiting API too, to allow seamless up/downgrades, or not.
[Corion]: Also, rate limiting will look great with await: my $token = await $limiter-> limit($hostname); instead of my $f = $limiter->limit( $hostname )->then(sub { my( $token)=@_; ... });

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (9)
As of 2017-10-23 08:25 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (277 votes). Check out past polls.