Open mkhan45 opened 2 years ago
causes other bugs
worth noting that elixir solves this by not letting closures be trivially recursive, the function has to accept a recursion function argument, e.g.
fib = fn(x, fib) -> if x < 2, do: n, else: fib.(n - 1, fib) + fib.(n - 2, fib) end
fib.(10, fib) |> IO.inspect # 55
https://github.com/mkhan45/RustScript2/blob/155b4c2c80b370a25f161d5a8b37678576f97eaf/lib/eval.ml#L483
The inner state recursive function needs to be thought about a bit more for continuation passing style to work