mkhan45 / RustScript2

RustScript is a functional scripting language with as much relation to Rust as Javascript has to Java.
https://mkhan45.github.io/RustScript2/
Other
36 stars 2 forks source link

recursive function resolution edge case #51

Open mkhan45 opened 2 years ago

mkhan45 commented 2 years ago

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

mkhan45 commented 2 years ago

causes other bugs

mkhan45 commented 2 years ago

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