One thing that is not very clear when using reason functions is figuring out which functions will throw an exception and which ones will not. This is also the case for functions that return an option (though not nearly as important for “glanceability” IMHO).
Jane Street has a convention to add _exn to all functions that will throw an exception as normal behavior. As an example, I think they have a List.find that returns an option and a List.find_exn that throws an exception.
It would be very helpful to allow ! and ? as valid variable keywords in Reason that get compiled to _exn and _opt for compatibility with OCaml/BS.
Having a ? for option would also help backward compatibility since List.find could be deprecated in favor of List.find? / List.find!
Perhaps this ship has sailed and it’s too late to be worth the breaking changes (even with a code mod) but I wanted to at least bring it up to the community for feedback!
- Yes!
- Meh, not worth the change
- No way!
0 voters