Every remotecall method currently has the function argument first so that do-block syntax can be used (#13338).
julia> methods(remotecall)
# 4 methods for generic function "remotecall":
remotecall(f, w::Base.Distributed.LocalProcess, args...; kwargs...) in Base.Distributed at distributed/remotecall.jl:318
remotecall(f, w::Base.Distributed.Worker, args...; kwargs...) in Base.Distributed at distributed/remotecall.jl:324
remotecall(f, id::Integer, args...; kwargs...) in Base.Distributed at distributed/remotecall.jl:336
remotecall(f, pool::Base.Distributed.AbstractWorkerPool, args...; kwargs...) in Base.Distributed at distributed/workerpool.jl:160
This is not the case for pmap, where the first argument is sometimes an AbstractWorkerPool. It would be great to make these consistent with each other and allow do-block syntax for pmap.
julia> methods(pmap)
# 4 methods for generic function "pmap":
pmap(p::Base.Distributed.AbstractWorkerPool, f, c; distributed, batch_size, on_error, retry_delays, retry_check) in Base.Distributed at distributed/pmap.jl:101
pmap(p::Base.Distributed.AbstractWorkerPool, f, c1, c...; kwargs...) in Base.Distributed at distributed/pmap.jl:155
pmap(f, c; kwargs...) in Base.Distributed at distributed/pmap.jl:156
pmap(f, c1, c...; kwargs...) in Base.Distributed at distributed/pmap.jl:157
cc @amitmurthy
Why not have syntax for passing the do function to any argument.
e.g. passing -> to any parameter means "pass the do function to this parameter".
So, the following would all be equivalent:
mapreduce(x->x, (a,b)->a+b, [1,2,3])
mapreduce((a,b)->a+b, [1,2,3]) do x
x
end
mapreduce(->, (a,b)->a+b, [1,2,3]) do x
x
end
mapreduce(x->x, ->, [1,2,3]) do a, b
a + b
end
Most helpful comment
Why not have syntax for passing the
dofunction to any argument.e.g. passing
->to any parameter means "pass thedofunction to this parameter".So, the following would all be equivalent: