On Sat, Mar 8, 2014 at 7:03 PM, andrew cooke <[email protected]> wrote:
> > i don't think anyone was doubting that iterators are more efficient than > tasks (me: "the only reason i can see for julia adding a separate mechanism > for iterators separate from tasks is efficiency; mike: "[coroutines...] > impossible to make iteration over custom data types fast or efficient."). > > what i was questioning more (although in a circumspect way, which i > thought was being poite but may have only been annoying) was whether there > is a need for (yet) another mechanism besides iterators and tasks. lazy > sequences (at least when i've used them) are equivalent to generators, so > are less expressive than tasks. and it seems the justification is one or > more of: (1) some (perhaps many) people find them easier to understand; (2) > they are more suited to some problems than others (and i was hoping to look > at the challenge posed for tasks at some point); (3) they are more > efficient than tasks (i don't think mike said this, but it may be true). > Lazy sequences aren't built into the language in any way – they're just something you can build since you have closures. They're a bit less expensive than tasks since each one doesn't need its own stack (each task/coroutine has its own stack), but they're still nowhere near as cheap or efficient as iterators. I'm personally not big on using lazy sequences, but they're good for some things – and we can't (and wouldn't want to) prevent people from implementing them. Not sure if that's answering the question or not.
