-
Notifications
You must be signed in to change notification settings - Fork 54
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
Decision on the behavior of map #4
Comments
So basically this behavior assumes that the function passed to In PooledArrays we recently made the opposite choice of assuming that |
I will note that I think this is the correct behavior, as |
I see the point of @ParadaCarleton, but then we should clearly document it as @nalimilan noted. Currently the documentation states a different contract, and e.g. DataFrames.jl relies on the current contract. @JeffBezanson - sorry to bother you, but |
I think current behavior is fine, Jeff says ugg |
There seem to be relevant discussions in:
FWIW, I'd love to see a spec that assumes purity of julia> rand.() .+ (1:5)
5-element Vector{Float64}:
1.6158199752768656
2.781538017460546
3.929416467969739
4.6286338994867435
5.9563765610939985 IIRC, @mbauman is in favor this behavior. (Maybe we should just have |
Following goerch's comment on Slack:
it is clear that we should define that As a minimum it should be documented. But my preference is what @tkf sugestted - make
|
As for the current documentation, it's ambiguous, but I actually lean towards the reading of it as assuming purity. "Transform collection With regards to whether it's preferable to use a Making In the very long run (2.0), the best solution might be to implement traits for functions, including a way to assert purity, and then throw an error when |
One good (if unfortunate) reason to use function cumsum(t::Tuple)
subTotal = 0
map(t) do elem
subTotal += elem
end
end If more functions gained the ability to maintain the collection type, or there were some Rust-eque |
Another possible API is to introduce an "executor" argument like |
A relevant comment -- modifying the behavior of In addition, removing the assumption of purity would contradict the behavior of |
I have just realized that the same applies to broadcasting:
@mbauman - is this intended? The Julia Manual states:
|
I'm honestly fine with pretty much any proposed behavior, but kicking the can down the road feels like the worst of both worlds. The longer we wait the more code gets written that could break, and it also makes it harder for me to write optimized code. |
Looking at the state of this issue (in particular not being tagged as "bug" by core devs) I understand that even if something changes here it will not happen until Julia 2.0 (as changing a non-bug behavior would be breaking). |
Oh, I agree with that, but it should at least be clearly documented whether this is a bug or not. As you mentioned, the devs not tagging it as a bug suggests to me that they think it's correct behavior (and I'd tend to agree). In that case, the documentation should clearly specify that We could also add a new function that explicitly doesn't require purity (I suggest |
It looks like FillArrays has been operating under the assumption that the
I'll gladly make a PR clearly documenting this, if one of the core devs can clarify that this is indeed intentional behavior. I'm less sure if I could implement something like |
It would make sense to make a doc PR to Base to get feedback from core devs. Clearly this issue is broader than SparseArrays or any other package. |
Note that in current julia, it is possible to ask the compiler this question using Base.infer_effects. |
As discussed in JuliaData/PooledArrays.jl#76 and JuliaData/DataFrames.jl#2957 here is the current behavior of
map
onSparseVector
:The question is if this is expected or a bug (my opinion is that it is a bug).
CC @nalimilan @ParadaCarleton
The text was updated successfully, but these errors were encountered: