-
Notifications
You must be signed in to change notification settings - Fork 150
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 all uses of @pure
#1130
base: master
Are you sure you want to change the base?
remove all uses of @pure
#1130
Conversation
I don't completely understand this: doesn't this imply that some of them were necessary in some capacity? In the diff, unless I missed something, it looks like they were all removed? Although I understand that automatic effects analysis and constant propagation can now figure much of this out on its own, this change seems to assume that it can figure all of these cases out now: shouldn't we verify this? Xref: related PR to *Core JuliaArrays/StaticArraysCore.jl#17 and earlier discussion JuliaArrays/StaticArraysCore.jl#1 (comment). in particular, I think the "should be sanity checks" bit from your earlier comment is important and not clear at present. |
Since @mateuszbaran asked on slack:
And since my answer is long, i thought i would just post it here.
Every singe one of them is wrong except:
And those ones are all trivial so it is "obvious"
all, they are all simple enough that they will all constant fold already with out this change.
No, none of them should be.
The first two are fine. But the last that uses
So the most common way (not saying only, but at least most common) things go wrong with incorrect To go into detail about why nothing has broken: So yes, this is relatively safe in practice, but it is also gaining nothing.
|
Thank you for a very detailed explanation! I will look into removing those uses of |
I will try to go slowly with removal of I don't know |
Its not possible for type variables to be not defined at runtime in julia. |
@oxinabox I'm pretty sure that's wrong. |
I keep forgetting how to trigger the case where |
Not sure if it's relevant for StaticArrays, but here's one way to trigger this: julia> f(::Type{<:Tuple}) = "fallback"
f (generic function with 1 method)
julia> f(::Type{<:Tuple{Vararg{T}}}) where {T} = (@isdefined T) ? "is defined" : "is not defined"
f (generic function with 2 methods)
julia> struct S end
julia> f(Tuple)
"fallback"
julia> f(Tuple{S})
"is defined"
julia> f(Tuple{T} where {T<:S})
"is defined"
julia> f(Tuple{Vararg{T}} where {T<:S})
"is not defined" |
Most of these were invalid uses of
@pure
and almost all of the rest were unnecessary.