But representing iteration this way in java programming can be inefficient because numerous recursive calls risk overflowing the stack 但在java编程中,用这种方式表示迭代将导致效率低下,因为大量的递归调用有导致堆栈溢出的危险。
It is caused by recursively descending a composite data structure in such a way that , sometimes , more than one step in the descent is taken in a single recursive call 它是由递归下行复合数据结构引起的,这种下行方式有时在一次递归调用中要下行多级。
But because the variable parameter values are sent to the recursive call all at once , it is much easier to get the updated values right than it is in a loop 但因为所有可变的参数值都一次传给了递归调用,所以比起循环来,在尾递归中可以更容易地得到更新值。
A loop does not have the overhead of passing arguments , initializing additional storage , and returning values . your performance can be much better without recursive calls 循环不会产生传递变量、初始化附加存储空间和返回值所需的开销,因此使用循环相对于使用递归调用可以大幅提高性能。
Because of this attribute , there is a nice correspondence between tail - recursive functions and loops : each recursive call can be thought of simply as one more iteration through a loop 由于这一特点,在尾递归函数和循环之间有一个很好的对应关系:可以简单地把每个递归调用看作是一个循环的多次迭代。