Hmm... I'll answer my best and you please tell me if that answers the question. First, context is accessed as context() property, in get-style:  my ( $a, $b, $c) = context and in set-style:  context $a, $b, $c.

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:

sub my_sleep(&) { print "sleeping ", context, "seconds\n"; &sleep(shift); }
And that is about it. If the caller wants to restart the call by
context 5; my_sleep { again if $again }
then the framework makes sure that 5 is still stored in the context, as my_sleep is called from within again().

Does that answers the question?


In reply to Re^6: IO::Lambda: call for participation by dk
in thread IO::Lambda: call for participation by dk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.