[e-lang] Dynamic whenever, composability of Ever*
mechanisms
Mark S. Miller
markm at caplet.com
Sat Apr 3 12:40:54 EST 2004
At 08:56 AM 4/3/2004 Saturday, Kevin Reid wrote:
>On Apr 2, 2004, at 17:44, Kevin Reid wrote:
>
>> whenever.makePairDynamic(inputReporters, thunk{formula()[0]}, interest)
>
>Oops. This should be:
>
> whenever.makePairDynamic(inputReporters, thunk{[formula(), []]}, interest)
Thanks, that makes more sense. Btw, I'm confused about the comment on that
method:
/**
* Like whenever/3, but returns a pair of an EverReporter and its
* EverReactor.
* <p>
* Useful if you want to manually subscribe the reactor to a dynamic set of
* inputs, but never unsubscribe from them, in which case this is more
* efficient than whenever.dynamic.
*/
to makePair(inputReporters :EverReporter[],
formula :near,
interest :near) :Tuple[EverReporter, EverReactor] {
whenever.makePairDynamic(inputReporters, thunk{formula()[0]}, interest)
}
In what way is whenever.makePair/3 more efficient than whenever.dynamic/3, given
how they are both implemented in terms of whenever.makePairDynamic?
(Here's whenever.dynamic/3:)
/**
* Like whenever/3, but the formula should return a tuple of the result
* and additional near EverReporters which the result depends upon.
*/
to dynamic(inputReporters :EverReporter[],
pairFormula :near,
interest :near) :EverReporter {
whenever.makePairDynamic(inputReporters, pairFormula, interest)[0]
}
--
Text by me above is hereby placed in the public domain
Cheers,
--MarkM
More information about the e-lang
mailing list