From: Jacob Fugal Date: 2005-09-03T08:20:15+09:00 Subject: Re: Idiomatic conversion of yielding block to array On 9/2/05, Simon Kr�ger wrote: > Jacob Fugal wrote: > > Why not something simple like so: > > ... ... > > because zip converts each argument to an array, which isn't what you > want if there are many lines. Ah, yes. I'd probably do it with SyncEnumerator rather than zip as well, then[1]. I just used zip since its what you started with and you didn't specify performance as an issue. > True SyncEnumerator does it with continuations but i wasn't ready for > this mind bending stuff (yet). (and now i don't need to make knots in my > brain, because Levin was so nice to tell us about SyncEnumerator) Very true. Thanks, Levin. > But what exactly isn't thread safe? SizedQueue is. Unless SizedQueue is built with threads in mind and does alternating blocking on pushes (<<) and pops. If it does, I apologize. Assuming I'm not wasting time by not looking at the SizedQueue documentation, the problem is that there's no guarantee that the main thread won't run several pops before returning control to the thread that's pushing into the queue. > Threads aren't evil. No, but naive non-thread-safe code is. Well, it's broken, at least... not necessarily *evil*. :) Jacob Fugal