3 ms·
It turns out that it is, in fact, at least mostly possible to implement a condition type system in Clojure. See https://www.youtube.com/watch?v=zp0OEDcAro0 htt
by nialo 10y ago
It turns out that it is, in fact, at least mostly possible to implement a condition type system in Clojure. See https://www.youtube.com/watch?v=zp0OEDcAro0 https://www.youtube.com/watch?v=zp0OEDcAro0
I did a little bit of googling for Clojure libraries that do this: https://github.com/zcaudate/ribol https://github.com/zcaudate/ribol and https://github.com/clojureman/special https://github.com/clojureman/special
I don't actually recommend any of these and haven't tried them. In particular I think using a non-standard library for your error handling, which is already probably relatively poorly tested, is probably a bad idea.
I just wanted to point out that it's possible. I also think I remember something in a Rich Hickey talk (maybe "Clojure for Lisp Programmers"?) where someone in the audience asks about condition systems, and he responds that Clojure doesn't have one, but that it should be possible to build it.
- jeremiep 10y agoThanks for pointing this out! I agree about being very careful in choosing to use such libraries! One concern I have is how well they integrate with the native exception system of the VM and what stopping on an error waiting for programmer input would mean in a lot of contexts. For example, stopping in a request handler while the programmer fixes the code will most likely trigger a timeout on the other end completely killing any advantage the condition system had in the first place. You've effectively bloated your programs with libraries you're not even taking advantage of :)
- fiddlerwoaroof 10y agoIn common lisp, during development, you can fix a surprising number of mistakes before the browser times out: especially mistakes involving things like typos. The other advantage of the condition/restart system is that it makes your libraries more reusable: rather than having either to choose one error handling strategy or to construct a system for choosing an error handling strategy, the language itself provides a construct for making several error handling strategies available that higher-level code can choose between in a straightforward manner.