squiggle icon indicating copy to clipboard operation
squiggle copied to clipboard

Don't fail on parse, analysis, runtime errors

Open berekuk opened this issue 1 year ago • 0 comments

Squiggle programs don't have to fail when execution can partially succeed. (Normal programs have side effects, so continuing execution is dangerous, but Squiggle is pure).

Examples:

  • when parse fails at line 100, we can still show all values from lines 1-99, and if the parser has recovered from an error, we can even continue execution below the failed line
  • when types don't match, we can highlight failed variables, but execute everything else
  • on runtime errors, we can store "VError" in the failed variable and proceed

One downside of this approach is that we'll consume more CPU: if your program is x = longComputation(); y = , and you're still typing the value for y, it'll run x more times.

But this can be improved with:

  • partial caches based on hashes of AST nodes
  • web workers
  • disabling autoruns, since it's only a problem when your entire program is slow

berekuk avatar Aug 30 '24 18:08 berekuk