-
Notifications
You must be signed in to change notification settings - Fork 94
Replace N field with result_index #999
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
Conversation
one question is do we want to add a deprecation on:
|
Codecov Report
@@ Coverage Diff @@
## master #999 +/- ##
==========================================
- Coverage 95.22% 95.21% -0.02%
==========================================
Files 99 99
Lines 11159 11233 +74
==========================================
+ Hits 10626 10695 +69
- Misses 533 538 +5
Continue to review full report at Codecov.
|
not sure the coverage makes sense here |
Still don't understand why. For instance, between Julia v0.x.y and v0.x.y+1, no deprecation where added, deprecation where only added between v0.x and v0.x+1. This allowed packages to write v0.x in their REQUIRE file and be sure that they users won't see any warnings. Then they will update their package for v0.x+1 using warnings to help them. |
Agreed. We don't want a patch release of MOI that causes all of the solver interfaces to start printing warnings. That's a bad user experience. |
sure but at least it creates a signal for the packages depending on MOI to fix the deprecations, which is much easier than looking for breaking changes in a changelog |
so would we prefer having deprecation warnings in a v0.10 or directly breaking changes? |
I prefer deprecation warnings in v0.10 rather than breaking changes when possible. |
I think the deprecation warnings will be useful to help update the wrappers before the first version compatible with MOI 0.10 is tagged. Secondarily, in the rare case where some part of the wrapper isn't updated, I'd rather a user see a deprecation warning than an error. |
Regarding a deprecation warning, it can be trickier than I thought. We would want to deprecate function Base.getproperty(attr:A, f::Symbol)
f2 = if f == :N
@warn "N has been deprecated, using attr.result_index instead"
:result_index
else
f
end
getfield(attr, f)
end The problem is that we add this level of indirection for all calls to Opinions? |
The I would prefer to see: function Base.getproperty(attr::Union{VariableValue}, field::Symbol)
if field == :N
@warn("The `.N` field has been deprecated. Use `.result_index` instead")
return getfield(attr, :result_index)
end
return getfield(attr, field)
end Where the union includes all the structs being changed. I don't think we can merge this before 0.10, however. |
yes I think this is the plan. This implies we have the warning and indirection staying for the whole 0.10 series and then being removed in 0.11 / 1.0 |
Julia uses constant propagation, so the struct Foo
b::Int
end
function Base.getproperty(f::Foo, field::Symbol)
if field == :a
@warn("Use `.b` instead.")
return getfield(f, :b)
end
return getfield(f, field)
end
struct Bar
b::Int
end
test_b(x) = x.b
f = Foo(1)
b = Bar(1)
julia> @code_llvm test_b(f)
; @ REPL[58]:1 within `test_b'
define i64 @julia_test_b_975([1 x i64]* nocapture nonnull readonly dereferenceable(8)) {
top:
; ┌ @ REPL[56]:6 within `getproperty'
%1 = getelementptr inbounds [1 x i64], [1 x i64]* %0, i64 0, i64 0
; └
%2 = load i64, i64* %1, align 8
ret i64 %2
}
julia> @code_llvm test_b(b)
; @ REPL[58]:1 within `test_b'
define i64 @julia_test_b_976([1 x i64]* nocapture nonnull readonly dereferenceable(8)) {
top:
; ┌ @ Base.jl:33 within `getproperty'
%1 = getelementptr inbounds [1 x i64], [1 x i64]* %0, i64 0, i64 0
; └
%2 = load i64, i64* %1, align 8
ret i64 %2
} |
The deprecations had to come after the definition of all attributes with this property, including |
CI will keep failing on nightly while this odd upstream problem remains |
Closes #960