Closed glenjamin closed 10 years ago
Since we're using try+ inside Dire, perhaps we can catch Object as seen in the second example? (https://github.com/scgilardi/slingshot#usage) It feels hacky though.
I still think there's something to implementing an arbitrary function dispatcher to help solve this problem. Having a lot of trouble visualizing how it should work though.
At any rate, I absolutely want to support Slingshot.
I added an implementation for arbitrary function dispatch on develop. While one still has to perform some set up for it to work well with Slingshot, it's a step in the right direction. https://github.com/MichaelDrogalis/dire/blob/develop/test/dire/test/dispatch_test.clj#L6
Another example: https://gist.github.com/MichaelDrogalis/5377029
@oneness
I think the only way to get slingshot sugar without just copy-pasting the matching functions, is to get slignshot to expose a catch+ function, which does the handling as seen at https://github.com/scgilardi/slingshot/blob/master/src/slingshot/support.clj#L179
Dire would then be able to do something like (catch Throwable e (catch+ e catch-clauses))
Yeah, after sleeping on it, I think you're right. There's also no reason to have arbitrary function dispatch if we have full slingshot support, given that for the custom dispatch to be useful, you'd be using throw+ anyhow.
I'll play around with copy-pasting the code in to make sure our assumptions are correct, then I'll talk to Phil about perhaps exposing catch+.
I am stuck on this, for the record.
I'm still intending to have a crack at this, when I get some time!
Certainly no rush!
With #17, this is done. :) Thanks @dparis !
Awesome work! I'd just put this back on my todo list - now I can cross it off already :)
Doesn't get much better than that! It's out on 0.5.0-SNAPSHOT
, and will be released as 0.5.0
tomorrow morning.
Glad it's working out! Let me know if you run across any problems with the new functionality.
From a cursory glance through the dire and slingshot code, I can't see a way to slot this in nicely.
I think what's needed is some of the code from slingshot's transform-catch, but at the moment the helper functions we'd need are hidden away in a letfn form.
https://github.com/scgilardi/slingshot/blob/master/src/slingshot/support.clj#L142