C tail call optimization

后端 未结 8 819
陌清茗
陌清茗 2021-01-31 16:25

I often hear people say that C doesn\'t perform tail call elimination. Even though it\'s not guaranteed by the standard, isn\'t it performed in practice by any decent implement

8条回答
  •  南方客
    南方客 (楼主)
    2021-01-31 17:20

    Although modern compilers MAY do tail-call optimization if you turn on optimizations, your debug builds will probably run without it so that you can get stack traces and step in/out of code and wonderful things like that. In this situation, tail call optimization is not desired.

    Since tail call optimization is not always desirable, it doesn't make sense to mandate it to compiler writers.

提交回复
热议问题