Why don't we have: Base.broadcastable(task::Task) = Ref(task)?

Is there any reason why Task is not made broadcastable using:

Base.broadcastable(task::Task) = Ref(task)

Currently, the below line fails if task_collection is a single Task (scalar):

x = fetch.(task_collection)
1 Like

That’s a good question! Maybe it was just missed.

On another note, I wonder why a variable named “task_collection” can even be just a Task, instead of an Array{Task,1} with only one element?


If as and bs are scalars, then task_collection will be a scalar (due to how broadcast works)

task_collection = @sync broadcast(as, bs) do a, b
    return @async do_longrunning_io_stuff(a,b)

I assume the pattern above could be the idiomatic way to use coroutines for calculating a collection of values where each value depends on some IO.