You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function p()
produce(1)
produce(2)
end
t = Task(p)
for i in 1:10
assert(!isempty(t))
end
With Julia commit 2990c29, this fails in the third iteration, because isempty consumes the task's outputs (which seems unusal for isempty(), IMO).
The isempty method that gets called is the one in iterator.jl:
isempty(itr) = done(itr, start(itr))
I do not know enough to comment on whether or not this implementation is appropriate for tasks.
One would 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.
The text was updated successfully, but these errors were encountered:
Consider this code:
With Julia commit 2990c29, this fails in the third iteration, because isempty consumes the task's outputs (which seems unusal for isempty(), IMO).
The isempty method that gets called is the one in iterator.jl:
I do not know enough to comment on whether or not this implementation is appropriate for tasks.
One would 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.
The text was updated successfully, but these errors were encountered: