|
|
|
|
|
by howeyc
4421 days ago
|
|
This was something I really loved during my time in Common Lisp. This was a gem that I was hoping would make it into Clojure, but I think around version 1.3 they decided to abandon the idea and add a library to "make anything throwable" which totally missed the point in my opinion. Are there any other languages that allow the calling scope to specify how lower-level functions handle errors without unwinding the stack? |
|
While it isn't a mainstream language by any means, a scheme dialect called muSE [1] that I developed for writing logic for automatic music video construction supports such resumes and retries. [2]
[1] https://code.google.com/p/muvee-symbolic-expressions/
[2] https://code.google.com/p/muvee-symbolic-expressions/wiki/Ex...
(Apologies for shameless plug)
-- edit: I just saw that the clojure library "ribol" has an api design similar to muSE's in principle. A couple of design comments though -
1. The "on blah blah" is too much syntax for this. It prevents direct sharing of handlers between similar situations. Function argument pattern matching ought to be enough.
2. The retry options mechanism is somewhat limited - the options seem to apply only at the raise point itself (disclaimer: I've only had a quick glance at ribol). It is more useful to have multiple retry options at different scopes so you can partially unwind, try something, if that doesn't work unwind some more (perhaps involving cleanup), try something else, etc.
I think muSE's design is better on both these fronts.