SodiumFRP / sodium

Sodium - Functional Reactive Programming (FRP) Library for multiple languages
http://sodium.nz/
Other
851 stars 140 forks source link

Java: Why do you need `suppressEarlierFirings`? #66

Closed romansl closed 8 years ago

romansl commented 9 years ago

In the switchS you pass suppressEarlierFirings=true to listen (Cell.java:426). Why?

the-real-blackh commented 9 years ago

I will think about this and check in a comment explaining it.

jam40jeff commented 8 years ago

This is to prevent the "switched to stream" from firing an event which clobbers the event fired by the "switched from stream". In the Denotational Semantics SwitchS example, cell c switches from stream s1 to stream s2 during the transaction at t = [1], but this should not take effect until the end of the transaction. Therefore, the code needs to start listening for events on s2, but ignoring any that are sent during that same transaction. That way, the event fired by s1 will be output rather than the simultaneous event fired by s2.