3 ms·
It can't not change the semantics of a language. It's basically automatic recursion-to-loop transformation (whether you call it "optimisation" or not is just a
by tomp 6y ago
It can't not change the semantics of a language. It's basically automatic recursion-to-loop transformation (whether you call it "optimisation" or not is just a semantic issue). So obviously will turn "infinite recursion but not really because it blows the stack" into "infinite loop".
But then many languages are quite loose with stack size requirement anyways, as well as stack traces (e.g. JVM's can include details about the internal implementation and/or automatic compiler transforms, e.g. concerning lambdas, methodhanles, invokedynamic etc).
- beagle3 6y agoIf you need an infinite loop (or very large iteration count), and rely on TCE but it is not available, the semantics of your program will change. In the "best" case, you'll get a stack overflow exception. In worse cases, your exception/condition system will kick in at a time which is essentially non-deterministic (it's usually deterministic but depends on a lost of things you may have no visibility into). But if TCE is available, you might even have no allocations after some startup. That's different semantics which are part of the language (e.g. in the case of Scheme) and thus not an "optimization".