# \[RFC/ANN\] FLoops.jl: fast generic for loops (foldl for humans™)

**URL:** <https://discourse.julialang.org/t/rfc-ann-floops-jl-fast-generic-for-loops-foldl-for-humans/37876>\
**Category:** Package Announcements\
**Created:** [April 20, 2020, 4:05am UTC](https://discourse.julialang.org/t/rfc-ann-floops-jl-fast-generic-for-loops-foldl-for-humans/37876 "2020-04-20T04:05:51Z")\
**Posts on this page:** 1\
**Showing post:** 38

<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:** [April 27, 2020, 5:58am UTC](https://discourse.julialang.org/t/rfc-ann-floops-jl-fast-generic-for-loops-foldl-for-humans/37876/38 "2020-04-27T05:58:31Z")

</div>

Thanks for elaborating the point. Maybe it’s better to tweak the manual and recommend

```julia
open(filename) do io
    for line in eachline(io)
        ...
    end
end

```

? Doing this is probably not super important for throw-away scripts but it is if you open a lot of files, implement long-running services, etc.

* * *

Re: CPS I just found

> <https://github.com/FluxML/IRTools.jl/blob/6d227c0edb828b7c761c97fe899dd33c03e69b56/examples/continuations.jl#L1-L6>

I guess it’s possible to define `iterate`/`foldl` from a single “function” definition syntax (something like Python’s `yield`, syntax-wise) by somehow hooking into this. Defining both `iterate` and `foldl` at the same time would be nice so that the “iterator” created by this syntax would work outside of the `foldl` API. It should also be possible to automate something like [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)

---

_[View the full topic](https://discourse.julialang.org/t/rfc-ann-floops-jl-fast-generic-for-loops-foldl-for-humans/37876)._
