-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Generalize ==
Documentation to not be Statistics-Specific
#53024
base: master
Are you sure you want to change the base?
Conversation
The `==` documentation made a special-case for the statistics community, specifically allowing a separate contract on `missing`. This denies extendability and only focuses the needs of only one small subset of the Julia community, which is something that is generally frowned upon. This change to the documentation instead describes the generalization of this process, where `(::T1 == ::T2)::Union{Bool, promote_type(T2)}`, which is a version of the contract that includes the `missing` case as part of the general rule, but covers other areas of the Julia community, including symbolic computing, statically-defined boolean types (Static.jl, FillArrays.jl), and makes a clear rule beyond just handling the `missing` special case.
==
Documentation to not be Statastics-Specific==
Documentation to not be Statistics-Specific
I don't have an opinion on whether this change is a good idea, but, considering that it changes public API, surely it's worthy of some discussion before it gets merged, or at least several approvals or something. |
if we have types while on the topic, should something be required like
|
It depends on which package has the dependency on the other. Only one of A or B should be able to define this, since only one of them can access both type definitions, and thus that is the one that "owns" it (without an extension package). If there is an extension package, then they need to coordinate on where that lives, so that it doesn't try to define it multiple times. |
There's also the special consideration for collections with missings in the following sentence. See also #52495. |
While this proposal loosens the written API, that API has already been profitably disregarded for years. As I recall, this issue was originally opened because If we're to have restrictions, shouldn't similar remarks be added to the inequality operators I think the most we could specify is that I would advocate to go further than this PR and remove any "formal API" regarding return types altogether. Actually insisting on an API would require breaking changes across numerous popular packages in the ecosystem and I don't see a real gain. What does an API achieve or improve? Has the varied use of |
IMO anything that returns a non- My reasoning for this is that loosening the expected contract of this means we're losing any expectation that |
I prefer less ambiguity, so perhaps my $0.02 is misplaced. That Given the lack of static analysis tooling, a programmer has no way to check that uses of |
Any breaking change is a Julia v2.0 discussion which is not on topic here. Can we please move any discussion of potential breaking changes to a separate issue? Since there's no plan for the 2.0, that is pretty irrelevant here.
Julia has stated within its documentation that
There seem to be comments missing some context about why it's common for packages to have dispatches to
These are cases which are "== in spirit", but allowing performance optimizations and delayed evaluation. When you then have to ensure lazy evaluation is made eager, that's |
To expand on what I wrote above, as far as I'm aware, it's only explicitly defined to give one non-
The fact that the ecosystem has ignored this and broken the contract in the standard execution/interpretation environment is IMO owed to the fact that Julia has been historically very lax in enforcing these kinds of contracts. The proposed reading/interpretation from this PR would pretty explicitly move
I do mean exactly that, in the sense that I think there should be no method of |
Lazy evaluation operates at the level of expressions (or partially-evaluated forms), which, indeed Julia enables quite well through the representation of expressions as parametric types (with multiple dispatch to glue everything together). The I am loathe to pose questions as response to a PR, but a clear answer is necessary:
|
I'm a bit puzzled by the discussion above, since julia> Trues(2) == Trues(2)
true and not julia> (Trues(2) .== Trues(2)) == Trues(2)
true |
The
==
documentation made a special-case for the statistics community, specifically allowing a separate contract onmissing
. This denies extendability and only focuses the needs of only one small subset of the Julia community, which is something that is generally frowned upon.This change to the documentation instead describes the generalization of this process, where
(::T1 == ::T2)::Union{Bool, promote_type(T2)}
, which is a version of the contract that includes themissing
case as part of the general rule, but covers other areas of the Julia community, including symbolic computing, statically-defined boolean types (Static.jl, FillArrays.jl), and makes a clear rule beyond just handling themissing
special case.