Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ::Function restrictions? #6

Closed
tkf opened this issue Feb 3, 2020 · 2 comments
Closed

Remove ::Function restrictions? #6

tkf opened this issue Feb 3, 2020 · 2 comments

Comments

@tkf
Copy link

tkf commented Feb 3, 2020

Re:

pforeach(pool, fn::Function, itr)
pforeach(fn::Function, pool, itr)

pmap(pool, fn::Function, itr)
pmap(fn::Function, pool, itr)

I'd suggest removing the restriction ::Function from pforeach(fn::Function, pool, itr) etc. since any object in Julia can be a callable. For relevant discussions, see JuliaLang/julia#34296 and JuliaLang/julia#30382. I think this comment by JeffBezanson is a nice summary (emphasis by me):

With multiple dispatch, just as the meaning of a function is important to get consistent, it's also important to get the meanings of the argument slots consistent when possible. It's not ideal for a function to treat an argument in a fundamentally different way based on its type: e.g. "if this is a Function, then call it on pairs of values, otherwise assume it's a container providing the values to use".

This makes having pforeach(pool, fn::Function, itr) a bit an uneasy choice. I think deprecating this method in 1.1 is a reasonable choice.

@tro3
Copy link
Owner

tro3 commented Jun 13, 2020

This one fell off my radar when I got busy the last few months. I am okay with the above, but how would the compiler differentiate pforeach(pool, fn::Function, itr) from pforeach(fn::Function, pool, itr)? I suppose pool could be typed.

@tkf
Copy link
Author

tkf commented Jun 13, 2020

Dispatching on a pool type sounds good to me. But this is tricky so that's why I recommended deprecating pforeach(pool, fn, itr). It's also what Jeff's comment is all about.

@tro3 tro3 closed this as completed in f28d7a0 Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants