Reactive programming

The responsive operations of spreadsheets is one of the features of the Scriptol to JavaScript language.

The react type defines a variable as reactive. Its value changes every time the value of variables assigned to it changes.


A, B, C are defined as reactive variables.

react A ​​= B + C * 10 

Whenever B or C will be assigned new values​​, the formula will be recalculated and A will take a new value.

By convention we write reactive variables in capital letters, even if any case is recognized by the compiler.

You have also to assign the output when a reactive variable controls a device or interact with a web page.


A.output = 'function() {document.getElementById("sum").value = this.value;}'; 

You can use either a simple quote or a multi-lines quote but not a double quote because the text could be transformed in the JavaScript code, and it is a case where it must not be changed.

The value of a reactive variable is updated only when the content of variables on which it depends is changed and if they are also reactive. Imperative variables in a reactive formula behave like they should do in imperative code and have no effect on other variable when their value is changed.
But if a reactive variable depends upon reactive and normal variables, and the reactive ones have a new value, then the reactive variable to which they are assigned takes into account the new value of the normal variable.