Go中的尾巴呼叫优化 [英] Tail Call Optimization in Go
问题描述
一个相对随机的可能微不足道的问题 - 到目前为止,Go编程语言是否优化尾部调用?如果没有,它是否至少优化函数的尾递归调用自身?
通过Internet可以找到的所有东西,Go在某些情况下支持可追踪递归,并且在中告知邮件列表:
在某些情况下,它已经存在于6g / 8g中,并且在gccgo中有些
多一般情况下。
我们目前并未计划改变语言,以要求
编译器在所有情况下都实施tail call优化。如果您必须
有一个尾部呼叫,您可以使用循环或goto语句。
要获得这些情况, d更好地挖掘 golang资源,该文档已打开。
A relatively random and probably trivial question - Does the Go programming language, as of now, optimize tail calls? If not, does it at least optimize tail-recursive calls of a function to itself?
Everything you can find over the Internet, that "Go supports tailable recursions in some cases", and that was told in mailing list:
It is already there in 6g/8g for certain cases, and in gccgo somewhat more generally.
We do not currently plan to change the language to require that compilers implement tail call optimization in all cases. If you must have a tail call, you use a loop or a goto statement.
To get those cases you'd better dig into golang source, which is open.
这篇关于Go中的尾巴呼叫优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!