import std.stdio; import core.thread : Fiber; void fib(ref int current){ current = 0; int next = 1; while(true){ Fiber.yield(); const next2 = current + next; current = next; next = next2; } } void test6_spawner(){ int current; Fiber fiber = new Fiber(() => fib(current)); int i = 0; while(i < 10){ fiber.call(); writef("%s ", current); i++; } } /* ./vtest2 hello here! 0 1 1 2 3 5 8 13 21 34 */