> Depending on implementation, infinite recursion is not guaranteed to blow 
> the stack for the program given. The function call is in tail position, so 
> a tail-call optimization (TCO) pass would be able to rewrite the program 
> into an infinite loop by reusing the existing stack frame for each 
> invocation of f[0].
>

Understood. But I think there are two reasons this code in the playground 
should still show an error:

1) The existing Go compilers don't do tail-call optimization, so keeping 
the discussion real and concrete, they will overflow the stack.
2) Even if they did implement tail-call optimization, this would be an 
infinite loop, so it should show a timeout error, like an infinite for loop 
does: https://go.dev/play/p/GH67vNtpZyp

-Ben
 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e4822715-caab-40b5-a345-9f5604e248cfn%40googlegroups.com.

Reply via email to