{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/18856","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/18856/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18856/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/18856/events","html_url":"https://github.com/JuliaLang/julia/pull/18856","id":181910048,"number":18856,"title":"WIP: Deprecate undefined == comparisons","user":{"login":"nalimilan","id":1120448,"avatar_url":"https://avatars.githubusercontent.com/u/1120448?v=3","gravatar_id":"","url":"https://api.github.com/users/nalimilan","html_url":"https://github.com/nalimilan","followers_url":"https://api.github.com/users/nalimilan/followers","following_url":"https://api.github.com/users/nalimilan/following{/other_user}","gists_url":"https://api.github.com/users/nalimilan/gists{/gist_id}","starred_url":"https://api.github.com/users/nalimilan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nalimilan/subscriptions","organizations_url":"https://api.github.com/users/nalimilan/orgs","repos_url":"https://api.github.com/users/nalimilan/repos","events_url":"https://api.github.com/users/nalimilan/events{/privacy}","received_events_url":"https://api.github.com/users/nalimilan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2016-10-09T20:44:39Z","updated_at":"2016-10-13T23:52:54Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/18856","html_url":"https://github.com/JuliaLang/julia/pull/18856","diff_url":"https://github.com/JuliaLang/julia/pull/18856.diff","patch_url":"https://github.com/JuliaLang/julia/pull/18856.patch"},"body":"This PR is a first stab at deprecating cross-type comparisons for which we previously fell back on `===` (https://github.com/JuliaLang/julia/issues/15983).\r\n\r\nThe first commit uses `===` where it makes sense and can be merged separately (https://github.com/JuliaLang/julia/pull/18853).\r\n\r\nThe second commit is more controversial, and could also be discussed in a separate PR: it changes all `in` and `find*` methods to use `isequal` consistently (until know only `Dict` did this for `in`). Relevant discussions are https://github.com/JuliaLang/julia/issues/9381 (about `in`), and https://github.com/JuliaLang/julia/issues/16269 and https://github.com/JuliaLang/julia/pull/18668 (about `find`). This change allows making `==` an error for arbitrary comparisons without breaking too much code. Indeed, it is relatively common to store heterogeneous non-comparable types in arrays or non-standard dicts (which use `==` contrary to `Dict`): in particular, strings and chars are stored together in the LineEdit/REPL code, but that's also the case of other high-level objects like `Base.Multimedia.display`. Note that this change is not *strictly* needed to make `==` throw an error for not-comparable types: the code could be made more careful instead. But I started with this minimally invasive strategy (in terms of lines of code to change) to be able to go to the next step without wasting time.\r\n\r\nThe third commit changes more comparisons to be robust against the change in behavior of `==`. It doesn't make much sense in isolation, but it doesn't break the tests either.\r\n\r\nThe fourth commit is the most interesting and challenging. Indeed, `isequal` falls back to `==`, yet we don't want the former to print deprecation warnings nor throw errors (after the next release). So we need a way for `isequal` to change the behavior of `==` for its needs. So far I've found two possible approaches:\r\n- Use a `try... catch` block to catch the `NotComparableError` thrown by `==`. This is unacceptable for performance unless the compiler is able to determine statically that the exception is thrown reliably by a method. Also, it doesn't work to silence deprecation warnings (for the first phase).\r\n- Use a mechanism similar to `@inbounds`/`@boundscheck` to tell `==` that no exception should be thrown. `isequal` would set this flag when calling `==`. This is the one I've retained here, temporarily abusing `@inbounds`; if we choose it, a separate macro would be warranted (e.g. `@comparable`).\r\nActually, this second approach is quite powerful, and it would offer a alternative behavior: instead of having `==` throw and `isequal` return `false`, both methods could throw by default, unless they are marked with `@comparable`. `in` and `find*` would use it by default to allow comparing arbitrary types. The advantage of this solution is that we wouldn't have to conflate two meanings into `isequal`: IEEE floating point semantics and arbitrary comparisons don't necessarily go together. The downside is that it could be more complex for users.\r\n\r\nAnyway, this is obviously quite rough. Comments and advice welcome."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/253672875","html_url":"https://github.com/JuliaLang/julia/pull/18856#issuecomment-253672875","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18856","id":253672875,"user":{"login":"davidanthoff","id":1036561,"avatar_url":"https://avatars.githubusercontent.com/u/1036561?v=3","gravatar_id":"","url":"https://api.github.com/users/davidanthoff","html_url":"https://github.com/davidanthoff","followers_url":"https://api.github.com/users/davidanthoff/followers","following_url":"https://api.github.com/users/davidanthoff/following{/other_user}","gists_url":"https://api.github.com/users/davidanthoff/gists{/gist_id}","starred_url":"https://api.github.com/users/davidanthoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidanthoff/subscriptions","organizations_url":"https://api.github.com/users/davidanthoff/orgs","repos_url":"https://api.github.com/users/davidanthoff/repos","events_url":"https://api.github.com/users/davidanthoff/events{/privacy}","received_events_url":"https://api.github.com/users/davidanthoff/received_events","type":"User","site_admin":false},"created_at":"2016-10-13T23:52:54Z","updated_at":"2016-10-13T23:52:54Z","body":"I'm not sure this is relevant here, so please feel free to ignore if this is off base. But for [Query.jl](https://github.com/davidanthoff/Query.jl) it would be really key that ``x::T == x::Nullable{T}`` works."}}
{"actor":{"display_login":"davidanthoff"}}