From: Jim Wise Date: 2012-10-11T04:28:14+09:00 Subject: Re: goto function? On Oct 10, 2012, at 06:05 , Peter Zotov wrote: > Eric Christopherson писал 10.10.2012 02:12: >> On Tue, Oct 9, 2012 at 4:45 PM, Frédéric Lemire wrote: >> ... >>> I like cleanliness and modularization, but I also like to have the eval >>> command, and metaprogramming stuff to explore sometimes unexpected ways. >>> So, why not a goto command ? >>> >>> It's neat to be able to get dirty when one needs it and feels confident >>> about it ! >>> >>> Anyway… for now, I'll just make exceptions to my indentation fixation, >>> waiting for a freer future. >> >> You can use continuations (although I think I recall hearing that they >> were either removed or dumbed down in 1.9). > > They were, in fact, added in 1.9. Neither, actually -- callcc is present in both 1.8.7 and 1.9, but was moved from the core to a stdlib in 1.9 (the 'continuation' module). However, callcc is not guaranteed to be present in all implementations (and is in fact not present in JRuby and MacRuby). I use callcc as the basis for the (mostly humorous/proof-of-concept) "reconsidered" gem, which -- to the original poster's question -- adds a limited form of goto to ruby, and for the more serious ambit gem, which provides nondeterministic programming for Ruby, and is the basis for the in-progress rulog logic programming system for Ruby. See: https://github.com/jimwise/ for more on reconsidered, ambit, and rulog. :-) -- Jim Wise jwise@draga.com