http://www.perlmonks.org?node_id=734362


in reply to Re^7: IO::Lambda: call for participation
in thread IO::Lambda: call for participation

Of course I don't mind questions, on the contrary, I'm interested to answer as much as I can, otherwise it won't be clear to me what parts of docs are insufficiently explained. So fire away!

With sleep, and all the predicates, I see where confusion stems from. All of the predicates accepts parameters on two stacks. The callback itself is the only parameter that is passed using perl stack, and all predicates have (&) signature for exactly that. All the other parameters are passed in the context.

Back to your question, a signature of sleep. The doc says that it is "sleep($deadline)", and is correct in that regard, because it omits two facts that all predicates a) have perl signature (&) and b) always deal with callbacks, so callbacks were not mentioned too.

Thus, passing the call as &sleep($deadline) is not correct, but &sleep($_[0]) is. sleep(&) expects the callback in $_[0], and deadline in context[0]. Hope that dissolves the confusion.

Finally, predicates. It seems that the word has many notions, and can be confusing. I'll need to document that term much more thoroughly, - or even consider another name?