-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Deprecate/remove map(f) and foreach(f) #35293
Comments
I've thought the same for a long time. There's a nice example of composition in haskell about how easy it is to do double map. The currying form allows things like:
I find this kind of thing comes up surprisingly often. |
Yet another reason to remove map(f, itrs...) == collect(f(args...) for args in zip(itrs...)) is not correct anymore for So the current behavior of Of course, currying for |
Quoting @StefanKarpinski's comment #31677 (comment)
So, I'm removing "RFC" from the title and adding |
I did mark that issue for triage since my opinion isn't really the final word, but if anyone else really objects, they can speak up. @JeffBezanson you got a strong opinion either way about this? |
Right, thanks for clarifying it. I just thought people are in more-or-less agreement and creating a PR would be effective to push it forward at this stage. But whoever creating the PR should know the "risk" that it could be rejected (although I think it's very low-risk). |
I don't have strong feelings about this, but it's hopefully unlikely to break anything in practice. |
The reason I doubt this will break things in practice is that the usual argument for the zero-arg case is that someone may have written generic code where the zero-arg case should work consistently for the sake of corner cases, but I just don't think people are writing much code using |
Yeah I agree the current meaning is pretty useless. |
Splatted maps that could potentially be affected by this: |
There are certainly cases there like |
Pretty much all the instances of |
We may need a different way of getting the curried version. We could say |
Hmm... I do have code that this will break.
Ideally though we wouldn’t have to create a new, ever-expanding set of generic functions to support currying. That seems to leave 3 options: syntax (like |
|
Triage says we should remove |
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. Corresponding PRs for stdlibs follow. Fixes JuliaLang#35293
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. Corresponding PRs for stdlibs follow. Fixes JuliaLang#35293
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. The `LinearAlgebra` stdlib will require a corresponding change. Fixes JuliaLang#35293
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. Fixes JuliaLang#35293
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. Fixes JuliaLang#35293
In the case of `map` and `foreach`, this removes awkward functionality. `Iterators.map(::Any)`, on the other hand, already throwed anyway. Fixes JuliaLang#35293
EDIT: see a more careful analysis below The Nanosoldier run on #52631 completed. I see at least these three packages that are broken by the change:
There's also a few other packages flagged as possible regressions by Nanosoldier, but I couldn't find any mention of "foreach" or "map" in their logs. |
Well that sounds encouraging. I still think this change is a good idea. |
Analysis of possible regressionsThe Nanosoldier report flags these packages as potential regressions:
Testing each package locally, 3ed49fd vs #52631:
For each package Analysis of each package1. EasyJobsBaseThe test failures are caused by the PR, in particular because of the lack of a 2. SimpleWorkflowsThis is depends on EasyJobsBase and shares the author. The tests again fail due 3. SetBuildersThis fails on master, I think the test is flaky. 4. FloatTrackerFlaky test. 5. ProgressMeterThe test failures are caused by the PR, the tests expect single-argument methods 6. GraphVizFlaky test. 7. GtkReactiveFor Nanosoldier, the testsuite passes on master but fails with the PR. For me,
8. OIFITSUnrelated error: segfaults on both master branch and PR branch, #52951. 9. IntensityScansWorks for me, so flaky. 10. PseudospectraUnrelated error: hangs. 11. SinogramsI guess this is a flaky hanger just like Pseudospectra, not going to test it. 12. MicroTrackerI guess this is a flaky hanger just like Pseudospectra, not going to test it. 13. ManifoldDiffSome kind of unrelated error happened during precompilation for Nanosoldier, but 14. TransitionsInTimeseriesSome kind of unrelated error happened during precompilation for Nanosoldier, but 15. BloqadeSome kind of unrelated error happened during precompilation for Nanosoldier, but 16. GMTUnrelated error, flaky. Sometimes segfaults, sometimes Julia vomits huge amounts of ConclusionMaking this change would break the test suites of three packages, but it doesn't |
PRs to the repos of packages with affected test suites: MineralsCloud/SimpleWorkflows.jl#207, MineralsCloud/EasyJobs.jl#57, timholy/ProgressMeter.jl#291. |
Single-argument `map` is being removed from Julia after an analysis of registered packages found that the change doesn't break the functionality of any package. See JuliaLang/julia#35293 and JuliaLang/julia#52631 That said, the Julia change breaks your test suite, so here's a PR that fixes that.
Thank you for this @nsajko! |
It might be useful to define curried version of iterator transforms such as
Iterators.map(f) = x -> Iterators.map(f, x)
(after #34352) andIterators.filter(f) = x -> Iterators.filter(f, x)
(ref #33027, #24990 (comment)). However, since the eager counter partmap(f)
is currently defined asf()
, it may confuse users when the difference betweenmap(f)
andIterators.map(f)
are more than laziness.Can we remove
map(f)
at some point? (I think whether or not it is desirable to do this within Julia 1.x is up to core devs.) I think it makes sense to also removeforeach(f)
when removingmap(f)
for consistency.map(f)
was added by @stevengj in #17318. The reasoning was that it is better to be consistent withf.()
. I agree that consideringf.()
as a special case off.(args...)
makes sense for broadcasting; i.e., the output dimension of broadcasting isreduce(max, ndims_of_arguments)
whenndims_of_arguments
is not empty. Sincendims
is always a non-negative integer, it is reasonable to use the identity element ofmax
on non-negative integers which is0
, when there is no argument. However, this argument relies on that the "ndims
" of the output is flexibly determined (i.e., using the largestndims
) in broadcasting. As this is not the case inmap
, I think it makes less sense to definemap(f)
asf()
. OTOH, I think curriedmap
is a useful definition.foreach(f)
was added by @JeffBezanson in #13774. It seems there was no discussion for addingforeach(f)
.The text was updated successfully, but these errors were encountered: