recursion means, that the program will call itself again
and not only that, via bind, it can even feed a value to the continuation
now, the recursion might be designed such that
it waits for the result from program that it spawned
a copy of itself, as a result of the call, that was recursive
and so that information would be needed to be kept
until the spawned recursive instance returns
now if the method runtime is stack based,
it will grow the stack, because the method calls are managed
by putting information in the stack.
now if the method runtime uses heap,
like the interpreter for a zio program
then the interpreter might choose to grow the head instead of the stack
and thus provide stack safety, for linear recursion
it's upto the runtime to choose the stack or the heap
-
since it is just a description of the program, it's a value object
that can be stored on heap, because it is treated as dead
with >>= you can recurse from inside a program
recursion means, that the program will call itself again and not only that, via bind, it can even feed a value to the continuation
now, the recursion might be designed such that it waits for the result from program that it spawned a copy of itself, as a result of the call, that was recursive and so that information would be needed to be kept until the spawned recursive instance returns
now if the method runtime is stack based, it will grow the stack, because the method calls are managed by putting information in the stack. now if the method runtime uses heap, like the interpreter for a zio program then the interpreter might choose to grow the head instead of the stack and thus provide stack safety, for linear recursion
it's upto the runtime to choose the stack or the heap
-
since it is just a description of the program, it's a value object that can be stored on heap, because it is treated as dead