http://github.com/jpalmucci/clj-return-from

On Jul 31, 12:41 pm, Sunil S Nandihalli <sunil.nandiha...@gmail.com>
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..
>
> Thanks,
> Sunil.
>
>
>
>
>
>
>
> On Sun, Jul 31, 2011 at 7:59 PM, Ken Wesson <kwess...@gmail.com> wrote:
> > On Sun, Jul 31, 2011 at 10:25 AM, Sunil S Nandihalli
> > <sunil.nandiha...@gmail.com> wrote:
> > > Hello everybody,
> > >  I would like to have a long running process to return its current
> > solution
> > > after some pre-determined amount of time. It so happens that the
> > iteration
> > > is happening at a deeper nested function. I would like to have a way to
> > > return from this nested function when its time ... How can I do this.
> > > Currently I am considering using the
> > > throw catch mechanism to do the job. Is there a better way of doing
> > things
> > > like this .. . I basically would like to have a non-local return ..
> > > something like the common-lisps return-from .. I
> > > found return-from equivalent in clojure.. I was hoping there is a nicer
> > way
> > > to deal with this when the function calls are quiet deeply nested..
>
> > Probably the least messy way to deal with it is to sprinkle
> > (Thread/sleep 0)s through the innermost loops of the algorithm, one in
> > each, and the outermost loop that refines the in-progress result has a
> > try ... catch for InterruptedException that handles it by returning
> > the current approximation. Then have a separate threat that calls
> > interrupt on the calculational thread on a timer, or if a user clicks
> > a Cancel button on a progress dialog, or whatever.
>
> > This is more or less what InterruptedException is for; and breaking
> > out of an algorithm in an unusual way is the kind of job for which
> > exceptions are well suited, as well as returning from fairly deep up
> > to a specific handler.
>
> > --
> > 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 clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> > your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/clojure?hl=en

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

Reply via email to