From: David Flanagan Date: 2007-11-09T15:22:24+09:00 Subject: Re: Frightening retry behavior should be deprecated and removed Yukihiro Matsumoto wrote: > Hi, > > In message "Re: Frightening retry behavior should be deprecated and removed" > on Wed, 7 Nov 2007 16:05:42 +0900, Charles Oliver Nutter writes: > > |I do not believe a target method should be able to cause the caller > |method to behave this way. I believe this behavior should be > |deprecated/removed. > > Since this feature is removed from 1.9, you can officially ignore this. > > matz. > It appears that retry can still do its magic re-evaluate the expression that invoked the iterator thing. But you can't hide the retry in a method or lambda definition, it can only appear in a block attached to the iterator, which makes it less frightening, since the person writing the method invocation expression that may be retried is the same person writing the retry statement. Matz: would it be correct to say that retry is now only allowed in rescue clauses and in blocks? And that it only works for local invocations of blocks, not in invocations of Procs? This code still works in 1.9: $tries = 0 (1..3).each { |x| print x; if x==3 if $tries < 3 $tries += 1 retry end end } But it doesn't work if we change the block to a Proc: $tries = 0 (1..3).each &lambda{ |x| print x; if x==3 if $tries < 3 $tries += 1 retry end end } And the fake-out-a-looping method thing does not work. # Does not work in 1.9 def repeat_while(x) if x # If the condition was not nil or false yield # Run the body of the loop retry # Retry and re-evaluate loop condition end end x = 5 repeat_while(x > 0) { puts x x -= 1 }