The idea that exceptions shouldn't be used for control flow doesn't change the fact that the solution you're proposing is a breaking change. How to properly handle exceptions is completely different from how exceptions are handled sometimes. Things are not always so obvious, even in hindsight. Additionally, no one wants to (and many don't have the resources to) hire a dev to track down why an upgrade broke their program that used to work.
That being said, I think spec will be able to help a lot moving forward. It can handle your nil case, the OP's bad input case, the OP's bad output case, and much more. I'm really hoping some specs ship with 1.9 so users can just call instrument-all and have a bunch of safety nets out-of-the-box, but we'll see.
Spec will definitely help, and I do understand the cost behind upgrading existing projects. However, I still firmly believe that it's important to try and address warts like that in the language. In the grand scheme of things, Clojure is still very small and now is the best time to make these kinds of changes.
Scala has been breaking things massively with pretty much every single release, and that has done little to impede its growth in popularity. Conversely, I'm pretty certain that some minor changes in Clojure that make it more consistent wouldn't be a huge deterrent to the overall user base either.
1
u/walkingthehotdog Jun 16 '16
The idea that exceptions shouldn't be used for control flow doesn't change the fact that the solution you're proposing is a breaking change. How to properly handle exceptions is completely different from how exceptions are handled sometimes. Things are not always so obvious, even in hindsight. Additionally, no one wants to (and many don't have the resources to) hire a dev to track down why an upgrade broke their program that used to work.
That being said, I think spec will be able to help a lot moving forward. It can handle your
nilcase, the OP's bad input case, the OP's bad output case, and much more. I'm really hoping some specs ship with 1.9 so users can just callinstrument-alland have a bunch of safety nets out-of-the-box, but we'll see.