-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize Discrete data type by calming simultaneous events #19
Comments
Just to clarify, you are saying here that your intent is not merely to optimize Discrete while keeping its current semantics, but rather to change its semantics in a significant (though honestly, probably better) way as part of the process of optimizing it, right? |
By-the-way, the more I have been thinking about the possible consequences of simultaneous events in my own event networks, the more that |
Well, I foreshadowed the intended semantics in the documentation: "Simultaneous events may be pruned for efficiency reasons." But yes, the |
That's fine, I was just making sure I understood this properly because it is a very significant change, as at the moment I have to code very cautiously using Discretes or in some cases avoid them altogether precisely because events are fired with "intermediate" results, and after your change I would not have to worry about this anymore. :-) |
Done! Commit 78bd983 in the development branch now contains the desired functions |
There, now it's done. The |
(This issue was kindly brought to my attention by Andrew Richards.)
Consider the following program:
The function
f
is called more than once per update of the single input, even though it is unnecessary to call it more than once. Is it possible to optimize theDiscrete
type to avoid this?Most likely yes, but I don't know how to perform this kind of optimization in the push-based implementation I currently have (version 0.4).
Basically,
Discrete
is implemented as a pairof a behavior (for recursion) and an update event. By duplicating
g
, the update event is also duplicated, resulting in two simultaneous update event occurrences for the eventout
. What's currently missing from reactive-banana is a combinatorthat removes all but the last event occurrence from a bunch of simultaneous events. This would allow us to optimize the Discrete data type. The combinator seems to be safe from a semantic point of view.
The text was updated successfully, but these errors were encountered: