Refactor tail call resolution logic

The tail call resolution logic was duplicated in `Environment::call` and
`VM::run`. This commit extracts the tail call resolution logic into a
single method `VM::resolve_tail_calls` and uses it in both places.

Additionally, this commit adds support for series indexing as a form of
tail call, allowing for direct access to series elements through the
`series(index)` syntax. This is useful for back-referencing in
time-series data.

A new example `err.myc` is added to demonstrate basic series usage and
error handling.
This commit is contained in:
Michael Schimmel
2026-03-06 12:35:00 +01:00
parent b9d88f019e
commit 13dc6beb52
4 changed files with 52 additions and 41 deletions
+6
View File
@@ -0,0 +1,6 @@
;; Output: 0
(do
(def history (series :float))
(push history 0.0)
(history 0)
)
+1
View File
@@ -10,6 +10,7 @@
(def sum (+ val (history 0)))
(push history sum)
(/ sum length)
(history 0)
))
)))