On Sun, Jul 31, 2011 at 12:41 PM, Sunil S Nandihalli
<[email protected]> wrote:
> Hi Ken,
>  thank you for your response. Do you think you can give me a quick example
> of how to extend an Exception to be able to extract the value from the
> exception when it is caught.. Should I be using gen-class for this? (seems
> quiet messy to me)... do you have a better suggestion..

Oh, I wasn't suggesting putting the data in the exception. From the
sounds of it you have something like

(defn outer-loop [...]
  (loop [x initial-value ...]
    (recur (compute-new-x x ...) ...)))

(defn compute-new-x [x ...]
  (...
    (further-computational-steps y ...)
    ...))

(defn further-computational-steps ...)

...

(defn deeply-nested-loop [q z foo]
  (loop [...]
    ...))

What I was suggesting was putting some quick thing in
deeply-nested-loop that will yield a timeslice and throw
InterruptedException if the thread's been interrupted, and in
outer-loop catch InterruptedException and handle it by returning the
current value of x:

(defn outer-loop [...]
  (loop [x initial-value ...]
    (let [[new-x ... interrupted?] (try
                          [(compute-new-x x ...) ... false]
                          (catch InterruptedException _ [nil nil nil ... true])]
      (if interrupted? x  (recur new-x ...)))))

-- 
Protege: What is this seething mass of parentheses?!
Master: Your father's Lisp REPL. This is the language of a true
hacker. Not as clumsy or random as C++; a language for a more
civilized age.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to