There are various levels of garbage collection and/or optimization that can be achieved when calling a function. Currently if you do any recursive call, even one in tail position, like this:
The stack will bloat with all the values of x and acc, even worse, this actually bloats the stack more than if you were to not use an accumulator, as it makes a new stack slot for x and acc every time fac_help is called.
We would like to support internal tail call optimization, if a call is in tail position than we update the stack with it's new values and just call the function again with it's variables (for instance x and acc) still pointing to the same place.
Additionally, temporary values should be garbage collected upon returning from a function.
There are various levels of garbage collection and/or optimization that can be achieved when calling a function. Currently if you do any recursive call, even one in tail position, like this:
The stack will bloat with all the values of x and acc, even worse, this actually bloats the stack more than if you were to not use an accumulator, as it makes a new stack slot for x and acc every time
fac_help
is called.We would like to support internal tail call optimization, if a call is in tail position than we update the stack with it's new values and just call the function again with it's variables (for instance
x
andacc
) still pointing to the same place.Additionally, temporary values should be garbage collected upon returning from a function.