#!/usr/bin/env ruby
CatchStack = []
def cc_catch(sym)
callcc { |cc|
CatchStack.push([sym, cc])
yield
}
ensure
CatchStack.pop
end
def cc_throw(sym, value=nil)
while ! CatchStack.empty? && CatchStack.last[0] != sym
CatchStack.pop
end
fail NameError, "uncaught throw `#{sym}'" if CatchStack.empty?
CatchStack.last[1].call(value)
end
|
|
[ Index ][ Presentation ] | Generated by [ source2html ] |