# Counting iterations to a type fixpoint

**URL:** <https://discourse.julialang.org/t/counting-iterations-to-a-type-fixpoint/75876>\
**Category:** General Usage\
**Created:** [February 5, 2022, 8:57pm UTC](https://discourse.julialang.org/t/counting-iterations-to-a-type-fixpoint/75876 "2022-02-05T20:57:41Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![tkf](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tkf/32/17635_2.png) [@tkf](https://discourse.julialang.org/u/tkf)\
**Post date:** [February 5, 2022, 10:46pm UTC](https://discourse.julialang.org/t/counting-iterations-to-a-type-fixpoint/75876/3 "2022-02-05T22:46:47Z")

</div>

I recommend using _functions_. Functions are more powerful than macros or `@generated` functions for solving problems like this. See tail-call function-barrier pattern I discussed in

- [State machines · Transducers.jl](https://juliafolds.github.io/Transducers.jl/dev/explanation/state_machines/)
- [Tail-call optimization and function-barrier -based accumulation in loops](https://discourse.julialang.org/t/tail-call-optimization-and-function-barrier-based-accumulation-in-loops/25831)

(At some previous versions of Transducers.jl, you could just write a simple loop FLoops.jl and the accumulator automatically converged to the fixpoint. But it is an opt-in feature ATM for “prelude” accumulator to reduce compile overhead.)

A generalized version of this is used in

- [[ANN] Catwalk.jl - With dynamic dispatch to the moon! (an adaptive optimizer, aka JIT compiler)](https://discourse.julialang.org/t/ann-catwalk-jl-with-dynamic-dispatch-to-the-moon-an-adaptive-optimizer-aka-jit-compiler/57917)

---

_[View the full topic](https://discourse.julialang.org/t/counting-iterations-to-a-type-fixpoint/75876)._
