3 ms·
> You can call that semantics if you like, but I think most people wouldn't. Tail Call Optimization (TCO) is an optimization, yes; but if Tail Call Eliminatio
by fsckboy 5y ago
> You can call that semantics if you like, but I think most people wouldn't.
Tail Call Optimization (TCO) is an optimization, yes;
but if Tail Call Elimination is required in the implementation of a language as it is in Scheme, then programmers in the language can rely on it (along with lexical scope) to write iterative loops instead as recursive calls. That is a change in program language semantics.
see Guy Steele's "Debunking the 'Expensive Procedure Call' Myth, or, Procedure Call Implementations Considered Harmful, or, Lambda: The Ultimate GOTO"
http://dspace.mit.edu/handle/1721.1/5753 http://dspace.mit.edu/handle/1721.1/5753
- cryptonector 5y agoMy point is that adding TCO is not a breaking semantics change, as its only visibility will be through a) the fact that more code works with it than w/o it, b) elision of tail-calling frames in stack traces. In particular I don't consider (b) to be a problem. I'm aware (b) is a matter of opinion, but really, TCO is much too valuable to use (b) as an argument against TCO.
- haberman 5y ago> but if Tail Call Elimination is required in the implementation of a language as it is in Scheme This is also supported as a non-standard extension in C, C++, and Objective-C as of Clang 13: https://clang.llvm.org/docs/AttributeReference.html#musttail https://clang.llvm.org/docs/AttributeReference.html#musttail (I implemented this). > see Guy Steele's "Debunking the 'Expensive Procedure Call' Myth Yes! :) I cited this paper in my blog article describing how we are using musttail: https://blog.reverberate.org/2021/04/21/musttail-efficient-interpreters.html https://blog.reverberate.org/2021/04/21/musttail-efficient-i...