-
Notifications
You must be signed in to change notification settings - Fork 150
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
Ability to opt out of "unsafe" methods #160
Comments
Yeah, this is a good point, but changing the API would:
That said, I'm not totally opposed to doing this and in fact would like to, while mitigating the effects of breaking changes. Currently playing around with the idea of introducing an Let's brainstorm a few more ideas :) |
stdlib Backwards compatibility is definitely important though. If I had a time machine, I might try to summon enough arrogance to argue for changing the interface in the past to what I want now, but that's not what I'm suggesting. The reason I say "opt out" is so that people can keep the API as is (if they actively want to use the throwing methods) or migrate at their leisure if they want to - even one enum at a time. I'm thinking something like this:
In userland, people can then choose to extend The indirection through type aliases (and the trait names I've written) are for illustration - you probably wouldn't want that in real life. At this point, I'm leaving open the possibility of letting users have the equivalent of Clearly you couldn't mix both All that said, if you actually are up for evolving the existing |
Ah, that sounds like the reverse of what I proposed, which is cool too. Either way, if we introduce a new trait for enums, we would need to figure out how to evolve the integrations too (which are mostly typed to |
Enum
gives youwithName
which throws, whether you like it or not. It also gives you "safe" versions but it discourages you from using them because they have longer names.It would be nice to be able to make the opposite choice: to have only the safe methods. E.g.
and variants. Or
Option
notTry
.People who really want to "force" the
Try
could callFoo.withName("bar").get
which would be visible to e.g. wartremover in user code.The text was updated successfully, but these errors were encountered: