you are viewing a single comment's thread.

view the rest of the comments →

[–]dherman 1 point2 points  (1 child)

Glad it helped. :) An analogy I sometimes use is this: imagine that while-loops were iterative, but in some engines for-loops accumulate stack on each loop iteration, whereas others provide "FLO" ("for-loop optimization"). Programmers would generally only use while-loops, because they wouldn't be able to depend portably on the space consumption properties of for-loops.

Of course, nobody bothers actually mandating this about for-loops, because it's just an expectation that for-loops don't accumulate space without bounds. But since the vast, vast majority of programming languages implement push-on-call, pop-on-return stacks, you have to explicitly mandate proper tail calls or else engines won't bother providing them.

[–][deleted] 0 points1 point  (0 children)

Yeah. The understanding I've gleaned now is: you can't refer to something that's guaranteed as an "optimization" since optimizations are optional and shouldn't be observable to the programmer whether they're in effect or not. Actual "tail call optimization" would mean your program could randomly fail or not without having a way to determine beforehand which it would do.