http://d.puremagic.com/issues/show_bug.cgi?id=5660
David Simcha <dsim...@yahoo.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |dsim...@yahoo.com --- Comment #1 from David Simcha <dsim...@yahoo.com> 2011-02-27 18:08:32 PST --- opApply plus fibers should do what you need. It's inefficient, but so is pretty much any coroutine/yield-based way of doing things, including Python's. I was thinking a while back that something like this belonged in std.range, but I wanted to handle ref properly, so Bug 2443 got in my way. Example (Warning: Untested.): /** This must be a class or otherwise have reference/heap-allocated semantics. */ class OpApplyToRange(Iterable) { Fiber fiber; ForeachType!Iterable _front; bool _empty; Iterable iterable; void doLoop() { foreach(elem; iterable) { _front = elem; Fiber.yield(); } _empty = true; } this(Iterable iterable) { this.iterable = iterable; fiber = new Fiber(&doLoop); fiber.call(); } void popFront() { fiber.call(); } ForeachType!Iterable front() @property { return _front; } bool empty() @property { return _empty; } } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------