hoplon / javelin

Spreadsheet-like dataflow programming in ClojureScript.
803 stars 44 forks source link

Cycle detection #43

Open alandipert opened 1 year ago

alandipert commented 1 year ago

It's possible to set cells in formulas, which makes it possible to inadvertently introduce cycles that cause propagation to run forever. This could happen when a formula function sets one of its dependencies, directly or indirectly, in the midst of propagation.

Currently, when this happens, the browser locks up and the user is left to find the cycle manually :joy:

Ken Tilton tells us that in his Cells library, he dynamically maintains a set of all active formulas. When a formula is invoked that is already present in the set, an error is signaled and the relevant dependency chain is printed.

I think we could probably easily do the same.

In addition, for cells created via macro, or that can otherwise carry source/line/column information, in our error message we could even potentially point to relevant places in code, to expedite debugging.