C# has a convenient way to create iterators using the
yield return statement. The package ResumableFunctions provides the same functionality for the Julia language by introducing the
@resumable and the
@yield macros. These macros can be used to replace the
Task switching functions
consume which were deprecated in Julia v0.6.
Channels are the preferred way for inter-task communication in julia v0.6+, but their performance is subpar for iterator applications.
using ResumableFunctions @resumable function fibonnaci(n::Int) a = 0 b = 1 for i in 1:n-1 @yield a a, b = b, a+b end a end for fib in fibonnaci(10) println(fib) end