This is because nobody has implemented isempty for Tasks, and is a nice catch for an issue to open on github :)
Searching for previous issues revealed that someone wanted isempty to work for general iterables in PR #5827<https://github.com/JuliaLang/julia/pull/5827>, and implemented it using the next() method that usually does not mutate anything, but currently Tasks are mutated on next(). One of the very nice properties of Julia is that you can just type *edit(isempty, (Task,))* and suddenly you see the definition of the function in the editor. isempty(itr) = done(itr, start(itr)) Ivar kl. 19:59:59 UTC+2 søndag 6. april 2014 skrev Micky Latowicki følgende: > > Hi. > > Having long admired Julia from afar, I've started messing with it today. > There's something I'd like to discuss about Tasks. > > Consider this code: > > function p() > produce(1) > produce(2) > end > > t = Task(p) > > for i in 1:10 > assert(!isempty(t)) > end > > This fails in the third iteration, because isempty consumes the task's > outputs (which seems unusal for isempty(), IMO). > > As a newbie, I expect isempty() to avoid modifying its argument, or at > least to avoid observable modifications. I don't think isempty() is very > useful when it consumes outputs - the caller probably has something to do > with those outputs, and would not like to discard them. So unless I'm > missing the intended usage, I suggest that isempty() either should not > exist for tasks, or (better) that there would be some 'look-ahead' buffer > in the task so that isempty can store the consumed element there, rather > than discard it. I realize that doing so might be a nontrivial modification. > > Opinions? > > Cheers > >
