Re:How Tail Call Optimization Works
by waynesonfire on Friday January 08, 2021 @02:28AM
(#25682460)
Joe Armstrong explaining the concept on the erlang mailing list in 2016, https://erlang.org/pipermail/erlang-questions/2016-October/0...
[ Parent
| on HN ]
I really like how Joe Armstrong speaks and writes so plainly. He always makes me feel good to learn from and not dumb.
Wow. I wish everything was explained so clearly. I understood everything in that post except this paragraph.
""" Languages like Erlang must implement tail call optimizations, since persisted data is stored as "loop variables" in infinite loops. This happens when we write code like this:
loop(Data) ->
....
...
loop(newData).
When I see code like this I mentally "see" the last call as a "jump"
to the start of the code, rather than a recursive call to loop.
"""What is the loop(Data), loop(newData) doing? Would be great if someone could elaborate on this point.