I think Flapjax can benefit from this idea. Here's an example of this pattern:
https://github.com/jpolitz/fj-world/blob/master/tests.html
And an implementation of the pattern:
https://github.com/jpolitz/fj-world/blob/master/flapjax-world.js
I've put type annotations in comments to help explain what's going on.
A World in Racket is a list of functions that abstract over shared
data, but each also has other, specific data related to the type of
event it handles, and this data is used to update the shared state.
I've implemented the merge-and-collect pattern in the world() function
multiple times before, and this abstraction will help me write similar
things in the future.
World programs in Racket come with other bells and whistles, but this
abstraction is the core of what's going on.
Parting thought: What should happen when the initial value given to
world() is itself a behavior?
Cheers,
Joe P.
If the world itself is an opaque value to the "operating system", then
shouldn't it make no difference what type the world is?
I'm pretty sure this is the right answer.
I had though about interpreting the intial values all as behaviors (the common
case of existing worlds would be a constantB), and attempting some sort of
lifting of the handlers over the behavior as well as over the eventstream
parameters. I was prompted by reading Flapjax's documentation, where many
parameterized values can also be time-varying. I'm mostly convinced that
constant values is the right choice here, however, for the reason you give.
--
Flapjax home page: www.flapjax-lang.org
Flapjax list: groups.google.com/group/flapjax
Post: fla...@googlegroups.com
Unsubscribe: flapjax-u...@googlegroups.com
var to_draw = w.liftB(P);insertDomB(to_draw, getObj('timer'), 'end');to just:insertDomB(P(w), getObj('timer'), 'end');Arjun