From: Gary Wright Date: 2007-12-08T13:39:10+09:00 Subject: Re: Clarification of retry change On Dec 7, 2007, at 10:54 PM, Charles Oliver Nutter wrote: > Michal Suchanek wrote: >> Hello >> When talking about the places where retry is allowed .. what does >> this >> imply for retry inside if, case, and while? >> I do not really use retry nor am I familiar with the grammar trees >> you >> keep talking about. Just want to remind that there are branching >> constructs inside which the retry might make sense (when placed >> inside >> a rescue). > > The scary thing is that what you're saying sounds totally sane, but > retry has never worked that way. retry outside of a rescue body has > always been a cross-method affair, causing the stack to unwind as > many calls as necessary to get back to a call that accepts a block > (and I think, unwind all the way back to the call that produced the > block where retry is happening...whew!). > > So the places you're talking about would all be forbidden locations > for retry in 1.9. What you want is redo, which already works for > looping constructs and is quite normal and predictable. You lost me there. retry is certainly legal and unambiguous within an if/case statement: begin puts "running.." raise rescue if rand(2)%2 == 0 retry end end Using retry within a while loop (within a rescue) raises the block/ iterator question yet again but if/case shouldn't be problematic at all, right? Gary Wright