Edward Faulkner
2/7/2006 8:36:00 PM
On Wed, Feb 08, 2006 at 03:54:39AM +0900, mental@rydia.net wrote:
> You could use continutations.
Indeed. With continuations you can build your own try/finally that
doesn't use the built in ruby begin/rescue at all:
$cc_stack = []
# takes two procs
def my_try(body, finally)
if callcc {|cc| $cc_stack << cc}
body.call
$cc_stack.pop
end
finally.call
end
def my_throw
$cc_stack.pop.call
end
You could play some tricks to get a nicer syntax, but that's the
general idea.
-Ed