> You must carefully not leaving any recursive functions not annotated with #[recursive]
Isn’t the same true of forgetting #[stacksafe]?
This reminds me of certain Haskell patterns where you selectively make some operations strict instead of lazy for similar reasons. I’m glad this library exists, but I’m sad the Rust compiler itself doesn’t have better support for recursion.
Why not just use a stack data structure instead of using the call stack as a stack data structure? Each stack frame is going to take up a lot more space than a straight array used as a stack.
While I am not versed in Rust, this type of problem has been addressed in other languages with a concept known as Free Monad[0], in which stack space is traded for heap space. While slower, it does eliminate the possibility of stack overflows.
Turns out, there is a Rust crate called higher_free_macro[1] which might fit the bill (to my novice Rust eye).
4 comments
[ 4.6 ms ] story [ 30.9 ms ] thread[1] https://docs.rs/tailcall/latest/tailcall/
Isn’t the same true of forgetting #[stacksafe]?
This reminds me of certain Haskell patterns where you selectively make some operations strict instead of lazy for similar reasons. I’m glad this library exists, but I’m sad the Rust compiler itself doesn’t have better support for recursion.
Turns out, there is a Rust crate called higher_free_macro[1] which might fit the bill (to my novice Rust eye).
0 - https://wiki.haskell.org/Free_structure#Free_Monads
1 - https://docs.rs/higher-free-macro/latest/higher_free_macro/