From: Morton Goldberg Date: 2006-07-22T09:55:33+09:00 Subject: Re: contine after exception I think I understand most of what you are doing here, and I think it's very nice. The one point that eludes me is purpose of the line: exp.instance_variable_set :@binding, bl Could you explain that. The code seems to work just fine even when that line is commented out. Regards, Morton On Jul 21, 2006, at 7:20 PM, Csaba Henk wrote: > module Exception::Continuable > > def try &bl > bl.call > rescue Exception => exp > callcc do |cc| > exp.instance_variable_set :@continuation, cc > exp.instance_variable_set :@binding, bl > class << exp > attr_reader :continuation, :binding > def continue > @continuation.call > end > end > raise exp > end > end > > end > > class Object > include Exception::Continuable > end > > class RetryException < Exception > end > > def printStuff(inpu) ## just print stuff > puts "printing" + inpu.to_s > if inpu == 3 > raise RetryException > end > end > > begin > [1,2,3,4,5,6,7,8].each{|value| try do printStuff(value) end } > rescue RetryException => err > puts " inside rescuedo nothing" > err.continue > rescue > puts "other exception" > ensure > puts "insode ensire" > end