in reply to Re^5: IO::Lambda: call for participation
in thread IO::Lambda: call for participation
When one is concerned only with calling predicate functions, such as tail() or read(), context is usually only set, and is not read. It's not impossible, just unneeded.
However, when one needs to write a custom function, that is on the receiving end of context, then the function needs to read the data passed through context. For example, you need to write a wrapper over IO::Lambda::sleep() that also prints number of seconds to sleep:
And that is about it. If the caller wants to restart the call bysub my_sleep(&) { print "sleeping ", context, "seconds\n"; &sleep(shift); }
then the framework makes sure that 5 is still stored in the context, as my_sleep is called from within again().context 5; my_sleep { again if $again }
Does that answers the question?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: IO::Lambda: call for participation
by zby (Vicar) on Jan 05, 2009 at 22:12 UTC | |
by dk (Chaplain) on Jan 06, 2009 at 07:41 UTC | |
by xdg (Monsignor) on Jan 06, 2009 at 13:55 UTC | |
by dk (Chaplain) on Jan 06, 2009 at 18:37 UTC | |
by ww (Archbishop) on Jan 06, 2009 at 14:18 UTC | |
by xdg (Monsignor) on Jan 06, 2009 at 22:56 UTC |