-
-
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
Adding comparison/hashing to Base.Some #35911
Comments
It would be great to understand your use case for this. The motivation for y = f(x) # obtain a value
y == Some(b) # compare in a lot of contexts it might be more idiomatic to do something(f(x)) == b Doing this also allows all operations that would be valid for the payload (eg |
The use cases which brought me here is that I ported an ExtensibleEffects framework to Julia. Within ExtensibleEffects I am working on container level, defining how containers translate to for loops, roughly speaking. In addition to for-loops, which only execute things, ExtensibleEffect construct appropriate return types.
The use of the ExtensibleEffects are of course only one example, anything which works on Container-Level semantics and needs to distinguish Container from Value would may use |
You also need
and the |
Also - I find the most effective way of getting something small like this is to submit a PR, if you are up for it? :) |
FYI, there is a PR for turning |
Nice! Though that PR still doesn’t add these comparisons/hash definition, which seem reasonable with or without considering it a “container”. |
I never setup Julia in development for creating pullrequest, but indeed this seems like a great occasion to go for it. @andyferris thanks for mentioning okay, so it is time for me to create my first pull request :) |
Dear Julia community,
what started as a short discourse discussion I would like to rephrase as a change request.
Currently,
Base.Some
is treated likeRef
in thatSome([]) != Some([])
, unlike Vector for instance. However in other programming languages,Some
actually behaves more like Vector in the sense that it is paired with Nothing and in this combination represents a Container of either one or zero elements.For instance in Scala
Some(List()) == Some(List())
.For consistency with the general semantics of Some/Option/Optional/Maybe (or however it might be called in other programming languages), I would plead for adding the following two lines to Base
This is a breaking change.
The text was updated successfully, but these errors were encountered: