Skip to content

Document in behaviour #647

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

Open
Tracked by #706
dpsanders opened this issue May 18, 2024 · 5 comments · May be fixed by #698 or #719
Open
Tracked by #706

Document in behaviour #647

dpsanders opened this issue May 18, 2024 · 5 comments · May be fixed by #698 or #719
Assignees
Labels
1.0 Planned for the major 1.0 release doc

Comments

@dpsanders
Copy link
Member

julia> 3.5  interval(3, 4)
false

This should either work or give me an error message telling me that this is not supported for intervals and telling me which special interval function to use instead (which is not discoverable).

@dpsanders
Copy link
Member Author

Apparently it's in_interval

@OlivierHnt OlivierHnt changed the title Set membership doesn't work Document in behaviour May 19, 2024
@OlivierHnt
Copy link
Member

I took the freedom of re-naming this issue since this behaviour is intentional and has been extensively discussed. In a nutshell, in Julia the function in pertains to containers (which Interval is not); we cannot remove it completely (throw an error) for otherwise some generic functions fail, we cannot overload it with our own definition since this leads to silent errors in generic code.

We should highlight this in the docs, and maybe just add a docstring for in?

@OlivierHnt OlivierHnt added 1.0 Planned for the major 1.0 release doc labels Jun 21, 2024
@OlivierHnt OlivierHnt linked a pull request Feb 21, 2025 that will close this issue
@OlivierHnt OlivierHnt linked a pull request Feb 21, 2025 that will close this issue
@Kolaru
Copy link
Collaborator

Kolaru commented May 3, 2025

I feel that we may have gone a long way since those discussions, and I am wondering if we shouldn't use the same trick for in that we use for ==, namely

3.2 in interval(3.2)  # True, because the interval is a singleton and `3.2 in 3.2` is true

3.2 in interval(7.9, 12.1)  # False, because for every x in the interval `3.2 in x` is  false

3.2 in interval(0.3, 7.1)  # Error, because no conclusion can be drawn

In fact, for numbers, == and in are equivalent, and we don't have that anymore in the package.

@OlivierHnt
Copy link
Member

OlivierHnt commented May 3, 2025

That does seem fair. In fact I believe that's what is implemented in the PR #698. Only functions like intersect, union, setdiff, isempty, are entirely prohibited because their behaviour is ambiguous (behaviour for Number vs Interval).

@Kolaru
Copy link
Collaborator

Kolaru commented May 16, 2025

In today's call we decide to be strict and consider by default that intervals are numbers but never sets with builtin julia function. In particular, this means in should be disabled as ambiguous.

Also, the documentation should contain a section on our general philosophy about it, so that we can refer to it in future discussion.

@Kolaru Kolaru self-assigned this May 16, 2025
@OlivierHnt OlivierHnt linked a pull request May 19, 2025 that will close this issue
@OlivierHnt OlivierHnt linked a pull request May 19, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0 Planned for the major 1.0 release doc
Projects
None yet
3 participants