"Rudolf Polzer" <denshimeiru-sapmctacher / durchnull.ath.cx> wrote: > > - coroutines and generators are obviously NOT contained in the rest of Ruby. > - goto is a subset of setjmp/jongjmp and therefore not in Ruby (or is it?) > > Well, you all know that goto can be done using case, well, at least something > similar: > > def goto(n) > $newlineno = n > end > def stop() > $newlineno = nil > end > > $lineno = 0 > while $lineno do > $newlineno = $lineno + 1 > case $lineno > when 100; puts "Hello World" > when 110; $i = 0 > when 120; if $i > 10 then goto 160 end > when 130; puts "Current $i: %d" % [$i] > when 140; $i = $i + 1 > when 150; goto 120 > when 160; puts "Done!" > when 170; stop > end > $lineno = $newlineno > end > > But that's no real goto, it's just case misuse. And possible even in > case-less languages like Perl using hashes or if... > > PLEASE DO NOT GIVE UP puts "Hello World" i = 0 callcc do | $goto160 | callcc {| $goto120 |} $goto160.call if i > 10 # 120; puts "Current i: %d" % [i] i = i + 1 $goto120.call end puts "Done!" # 160; daz