You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code in https://gist.github.com/beberlei/4145442 changes the recursive call in line 49 to be a call to the instance variable $func, which in turn is changed in the line 19. Through that then the recursive calls return immediately, storing the arguments in the $acc instance variable. The re-implementation in functional-php does not do that, rendering the tail_recursion a noop.
The code in https://gist.github.com/beberlei/4145442 changes the recursive call in line 49 to be a call to the instance variable
$func
, which in turn is changed in the line 19. Through that then the recursive calls return immediately, storing the arguments in the$acc
instance variable. The re-implementation in functional-php does not do that, rendering thetail_recursion
a noop.Compare the output of these two scripts:
functional-php code
The output is:
highlighting 10 stack frames are used.
While the gist linked:
produces:
Maybe a solution can be implemented using reflection and renaming the function?
The text was updated successfully, but these errors were encountered: