Re: Everyone's favorite flow control: retry



On Dec 3, 8:22 pm, Charles Oliver Nutter <charles.nut...@xxxxxxx>
wrote:
MonkeeSage wrote:
As I understand, it's like a label in C. Charles' first example is
equivalent to something like this...

#include <stdio.h>
void foo(int (*pf)(const char *f, ...), char *a) {
(*pf)("%s\n", a);
}
int main() {
retry:
foo(&printf, "123");
goto retry;
return 0;
}

It's more than that...here's some pseudo C code:

void foo() { goto retry; }
int main() {
retry:
foo();
return 0;

}

Retry outside a rescue actually allows you to jump back across call
boundaries and start an invocation again. Scary.

- Charlie

Ah. How does it unwind the stack like that? Is that what you meant
about implementation specific stuff?

Ps. I don't think anyone will miss retry outside of a rescue. I won't
at least. :)

Regards,
Jordan
.



Relevant Pages