Re:Rust will likely not support tail call optimization
by dewitt on Wednesday April 10, 2013 @03:39PM
(#5527543)
Right. In Clojure you'd use an explicit trampoline for stack-free mutual recursion.
[ Parent
| on HN ]
Re:Rust will likely not support tail call optimization
by andrewvc on Wednesday April 10, 2013 @04:58PM
(#5528116)
Mutual TCO is really uncommon for what it's worth. Of you need it that bad a trampoline should suffice
Re:Rust will likely not support tail call optimization
by kvb on Wednesday April 10, 2013 @05:07PM
(#5528176)
Direct mutual recursion is somewhat rare (but useful for encoding state machines, for instance). However, using continuation passing style (and tail calls to a continuation argument) to prevent stack overflow is a common idiom in some functional languages (e.g. when mapping over a binary tree).
Re:Rust will likely not support tail call optimization
by derefr on Wednesday April 10, 2013 @10:00PM
(#5529481)
Erlang uses mutual TCO everywhere. All actors/processes are state machines with the function they're in being their current state. To switch states, you just tail-call a new function (which doesn't have to be from the same module you were in.)