From: Simen Edvardsen Date: 2006-08-16T23:05:03+09:00 Subject: Re: goto function? On 8/16/06, Christian Neukirchen wrote: > "David Vallner" writes: > > > The BASIC construct of "goto" is rightfully considered harmful for > > programs above a certain complexity. It's not present in Ruby in any > > direct way that would let you jump around a program's structure > > arbitrarily. (Actually, that's a lie, but I'll hold the continuations > > for the sake of simplicity.) > > It is often said that continuations are as powerful as goto. > But is there a way to jump *forward* with continuations, without > rewriting the code to use additional methods? > > > David Vallner > -- > Christian Neukirchen http://chneukirchen.org > > A continuation is, by definition, the *continuation* of the computation. But that probably wasn't the answer you wanted. There's no way to do: goto :a label :a Even though it's easy to create label and goto methods that work like this: label :a puts "after a" goto :a if rand(2) % 2 == 0 -- - Simen