Re:Not Lisp again (2009)
by spc476 on Thursday March 14, 2013 @03:12PM
(#5377023)
Lua does TCO and implements it with a special opcode that tracks the number of times a function is called, and you can get an accurate stack dump.
But one reason why I like TCO is in writing code to handle protocols. Create a state machine that describes the protocol. Convert each state to a function. Transitions to a another state is a function call. It works something like:
Because of TCO, each function call is effectively a GOTO. I've used this method to implement TFTP.
[ Parent
| on HN ]
There are no comments on this comment yet.