We have issue #23 for general tail recursion in Metaprob. But there is a special case that may be easier to implement, and which would be useful in a number of common cases.
The idea is that we could enable tail-recursive calls within untraced functions. Use cases include map:
(define map
(gen [f l]
(with-explicit-tracer t
(define helper
(gen [l acc i]
(if (empty? l)
acc
(recur (rest l) (cons (t i f (first l)) acc) (+ i 1)))
(helper l '() 0))))
and reduce, replicate, etc. Even though this may be simpler than implementing full TCE in Metaprob, it will still require some implementation work; even though the recursive call is untraced, it can still produce a score (so scores will likely need to be threaded through the interpreter).
We have issue #23 for general tail recursion in Metaprob. But there is a special case that may be easier to implement, and which would be useful in a number of common cases.
The idea is that we could enable tail-recursive calls within untraced functions. Use cases include
map
:and reduce, replicate, etc. Even though this may be simpler than implementing full TCE in Metaprob, it will still require some implementation work; even though the recursive call is untraced, it can still produce a score (so scores will likely need to be threaded through the interpreter).