Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was just wondering if a language could support something like a Retry/Fix block?

The answer to this question is probably the reason it's a bad idea or equivalent to something else, but the idea keeps popping into my head.

void F()
  fix(WrongNumber wn, out int x)
    x = 1;

void G()
  int x = 0;
    if(x != 1) throw new WrongNumber(x);

After the fix block ran, the retry block would run again...

share|improve this question
How would that be different from a catch block? – Caleb May 30 '12 at 22:22
because after the fix block the retry block would run again? that's what i was thinking at least. – Aaron Anodide May 30 '12 at 22:23
We already have it, it's named Eiffel. I do remember a similar clause in a yet another language which name I cannot recollect now. – 9000 May 30 '12 at 22:23
Yet another obscure control structure a lisp hacker can implement with call/cc and a thirty line macro... that is, if they didn't already do it. – delnan May 30 '12 at 22:25
Even Visual Basic has it: On Error Goto X / Resume Next – MSalters May 31 '12 at 9:06
up vote 3 down vote accepted

Yes, a language could do that.

There are examples in existing languages. Common Lisp provides a system which allows an exception (condition, in CL terminology) handler to return control to the point at which the exception was thrown, passing extra information about how the condition should be handled.

A good description of this is available in the book Practical Common Lisp, 19. Beyond Exception Handling: Conditions and Restarts

As other commenters have mentioned, Scheme's general continuation system could be used to implement this, and Eiffel provides similar functionality.

Thanks to @9000 and @delnan for bringing up Eiffel and call/cc in the comments on the question

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.