* * * * *
My stance of tail call optimizations has changed over time
In writing the previous entry [1], I came across a post I made ten years ago
about tail call optmization [2] where I stated that I disliked it. But that
was then, this is now, and now, I like tail call optimizations.
At the time I wrote that, I only thought tail call optimzations applied to a
certain class of recursive functions, but no, it can be done in non-recursive
functions as well [3]. There may be limitations in when it can be done [4],
but it's applicable to more than just recursive functions.
It's just a shame that such things are taught poorly and with bad examples
(if at all—the term “tail call optimization” never came up in college). Of
course, it would help if the language used for teaching supported the
concepts as well (when I was in college, it was FORTRAN-77, Pascal and C—I'm
not sure if FORTRAN-77 even supports recursion; Pascal was a pedagogical
language designed by a computer scientist [5] well known for being critical
of the computer industry; and C was just a step above assembly language).
Even some population langauges used for teaching today (cough—Python—cough)
don't support tail call optimization [6] because it's confusing or something.
Sheesh.
[1]
gopher://gopher.conman.org/0Phlog:2017/11/05.1
[2]
gopher://gopher.conman.org/0Phlog:2007/10/19.1
[3]
gopher://gopher.conman.org/0Phlog:2013/03/22.2
[4]
gopher://gopher.conman.org/0Phlog:2013/03/25.1
[5]
https://en.wikipedia.org/wiki/Niklaus_Wirth
[6]
http://neopythonic.blogspot.com.au/2009/04/final-words-on-tail-calls.html
Email author at
[email protected]