proc/test_while()
while(1)
x++
sleep(1)
vs
proc/test_spawn()
x++
spawn(1) test_spawn()
It is my understanding that the test_while() will never return, but test_spawn() will return after every spawn(1) call. test_spawn() is scheduling a new call every 10th second but is also returning within the tick its called. Also, the object that test_while() belongs to can't be garbage collected unless there's a break case or a return.
I would like to know a little more about the stack specifically. I've tested situations where recursive spawn() is actually more efficient than while() which is strange considering I think spawn() should have more overhead with the constant stacking.
It is not clear to me when to choose to use one method over the other.