This is a natural generalization of the function barrier + mutate-or-widen approach used in functions like collect
. So, I think it might be natural to have it in Julia: Tail-call optimization and function-barrier -based accumulation in loops - #8 by tkf