Skip to content

Conversation

@nsajko
Copy link
Member

@nsajko nsajko commented Dec 26, 2023

In the case of map and foreach, this removes awkward functionality. Iterators.map(::Any), on the other hand, already throwed anyway.

Fixes #35293

@nsajko nsajko force-pushed the empty_map branch 4 times, most recently from a514e3d to 4f5da74 Compare December 26, 2023 11:16
@nsajko
Copy link
Member Author

nsajko commented Dec 27, 2023

The test failures seem unrelated (they're system-specific).

@nsajko
Copy link
Member Author

nsajko commented Dec 28, 2023

I guess this should get a Nanosoldier PkgEval run (the issue this fixes is marked as breaking).

@nsajko nsajko added the needs pkgeval Tests for all registered packages should be run with this change label Jan 15, 2024
In the case of `map` and `foreach`, this removes awkward functionality.
`Iterators.map(::Any)`, on the other hand, already throwed anyway.

Fixes JuliaLang#35293
@nsajko
Copy link
Member Author

nsajko commented Jan 16, 2024

Fixed conflict.

@timholy timholy added the breaking This change will break code label Jan 16, 2024
@maleadt
Copy link
Member

maleadt commented Jan 16, 2024

@nanosoldier runtests()

@nanosoldier
Copy link
Collaborator

The package evaluation job you requested has completed - possible new issues were detected.
The full report is available.

@nsajko nsajko removed the needs pkgeval Tests for all registered packages should be run with this change label Jan 16, 2024
@andyferris
Copy link
Member

I, for one, support this change. LGTM.

@timholy
Copy link
Member

timholy commented Jan 17, 2024

@nsajko if you can analyze the errors and report whether they're real, that would likely help decide whether this is feasible.

@nsajko
Copy link
Member Author

nsajko commented Jan 18, 2024

@timholy the analysis is on the #35293 page. One of your packages, ProgressMeter, is mentioned.

@LilithHafner LilithHafner added minor change Marginal behavior change acceptable for a minor release and removed breaking This change will break code labels Jan 18, 2024
Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given widespread approval, limited opposition, triage approval, and a nanosoldier run that, according to @nsajko's detailed analysis, revealed no real breakages, this LGTM from a breakage standpoint.

The implementation looks complete and sufficiently tested.

@LilithHafner LilithHafner added the merge me PR is reviewed. Merge when all tests are passing label Jan 18, 2024
MarcMush pushed a commit to timholy/ProgressMeter.jl that referenced this pull request Jan 18, 2024
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.
@LilithHafner LilithHafner merged commit a28e553 into JuliaLang:master Jan 18, 2024
@LilithHafner LilithHafner removed the merge me PR is reviewed. Merge when all tests are passing label Jan 18, 2024
@mikmoore
Copy link
Contributor

Should reduce/foldl/foldr, and their map* variants have been included with this change? I'm sure there are arguments for either direction.

@LilithHafner
Copy link
Member

I think they should have also been included. If someone makes a PR soon I think those removals should be backported to 1.11 so they land with this one.

As long as they are not widely used, I oppose the existence of those methods on the same grounds as map(f) = [f()]: the mathematically consistent implementation is map(f) = [f() for _ in 1:Inf], which folks don't want.

@nsajko
Copy link
Member Author

nsajko commented Feb 16, 2024

Should reduce/foldl/foldr, and their map* variants have been included with this change?

Those weren't part of the linked issue, so presumably they're not covered with the triage decision. A new issue should be opened IMO, and discussed by triage I guess.

@LilithHafner
Copy link
Member

No need to get triage approval to open a PR! (plus, we need a PR to run nanosoldier which will inform decisionmaking)

@LilithHafner
Copy link
Member

(Though I would want to bring this back to triage before merging such a PR)

@dlfivefifty
Copy link
Contributor

[f() for _ in 1:Inf]

In case this is something you actually want this works:

julia> using InfiniteArrays

julia> f = () -> 1
#5 (generic function with 1 method)

julia> [f() for _ = 1:∞]
#7.(ℵ₀-element InfiniteArrays.InfUnitRange{Int64} with indices OneToInf()) with indices OneToInf():
 1
 1
 1
 1
 1
 1
 1
 1
 1
 

nsajko added a commit to nsajko/julia that referenced this pull request Apr 15, 2024
PR JuliaLang#52631 made `map` throw `MethodError` when called without an
iterator argument. That made `mapreduce` throw `MethodError` when
called without an iterator argument, too, something that was *not*
noticed back then. This change makes iteratorless `mapreduce` throw
before it can be called, instead of when it tries to call `map` without
passing it an iterator argument.

After this change all of these functions should only have methods that
take a positive number of iterator arguments:

1. `map`
2. `Iterators.map`
3. `foreach`
4. `reduce`
5. `foldl`
6. `foldr`
7. `mapreduce`
8. `mapfoldl`
9. `mapfoldr`
nsajko added a commit to nsajko/julia that referenced this pull request Apr 15, 2024
PR JuliaLang#52631 made `map` throw `MethodError` when called without an
iterator argument. That made `mapreduce` throw `MethodError` when
called without an iterator argument, too, something that was *not*
noticed back then. This change makes iteratorless `mapreduce` throw
before it can be called, instead of when it tries to call `map` (or
`Generator`) without passing it an iterator argument.

Now all of these functions should only have methods that take a
positive number of iterator arguments, which improves consistency:

1. `map`
2. `Iterators.map`
3. `foreach`
4. `reduce`
5. `foldl`
6. `foldr`
7. `mapreduce`
8. `mapfoldl`
9. `mapfoldr`
10. `Base.Generator`
@nsajko
Copy link
Member Author

nsajko commented Apr 15, 2024

Followup: #54088

oscardssmith pushed a commit that referenced this pull request Apr 26, 2024
PR #52631 made `map` throw `MethodError` when called without an iterator
argument. That made `mapreduce` throw `MethodError` when called without
an iterator argument, too, something that was *not* noticed back then.
This change makes iteratorless `mapreduce` throw before it can be
called, instead of when it tries to call `map` (or `Generator`) without
passing it an iterator argument.

Now all of these functions should only have methods that take a positive
number of iterator arguments, which improves consistency:

1. `map`
2. `Iterators.map`
3. `foreach`
4. `reduce`
5. `foldl`
6. `foldr`
7. `mapreduce`
8. `mapfoldl`
9. `mapfoldr`
10. `Base.Generator`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor change Marginal behavior change acceptable for a minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate/remove map(f) and foreach(f)

8 participants