Retry from proc-closure (LocalJumpError)

咳といいます。

助けてください。
1.9のdRubyのretryのテストで困っています。

1.8で発生していたLocalJumpErrorが発生しなくなってしまい、
dRubyでretryを捕まえられなくなりました。
1.9ではどんな風にしたらよいでしょうか。

% cat retry.rb
def test_retry
first = true
block = Proc.new do |x|
p x
if first
first = false
retry
end
end
[1].each do |x|
block.call(x)
end
end

test_retry

% ruby -v
ruby 1.8.6 (2007-11-13 patchlevel 5000) [powerpc-darwin9.0.0]

% ruby retry.rb
1
retry.rb:7:in call': retry from proc-closure (LocalJumpError) from retry.rb:11:intest_retry’
from retry.rb:10:in each' from retry.rb:10:intest_retry’
from retry.rb:15

1.9では次のようになります‥

% ruby19 -v
ruby 1.9.0 (2007-11-26 patchlevel 0) [powerpc-darwin9.1.0]
% ruby19 retry.rb
1
1

e$B31$H$$$$$^$9!#e(B

e$B:{ED$5$s$"$j$,$H$&$4$6$$$^$9!#e(B

On 2007/12/19, at 18:19, SASADA Koichi wrote:

e$B!!$^$:!$A0Ds$H$7$F!$e(BRuby 1.9 e$B$G$O%V%m%C%/Cf$K5-=R$9$ke(B
retry e$B$,$J$/$Je(B
e$B$j$^$7$?!%$3$l$O!$e(Bruby-core [email protected]$G!$$^$D$be(B
e$B$H$5$s$,$=$&7h$ae(B
e$B$^$7$?!%e(B

e$BN,e(B

e$B!!$H$$$&$o$1$G!$$3$NLdBj$O2r7h$H$$$&$3$H$GNI$$$G$7$g$&$+!%e(B

e$BN;2r$7$^$7$?!#e(B

e$B!!$A$J$$K!$:#F|$N%3%%C%H$Ge(B retry e$B$r:o$C$?$N$G$9$,!$e(Bdrb
e$B$Ne(B lib,
sample e$B$N$[$&$GBP1~$9$k$H;W$o$l$k%3!<%I$r:o$i$;[email protected]$-$^e(B
e$B$7$?!J%3e(B
e$B%s%Q%$%k;~$K%(%i!<$K$J$k$N$G!$;D$C$F$$$k$H%F%9%H$,DL$i$J$/e(B
e$B$J$k!K!%$9e(B
e$B$_$^$;$s$,!$$43NG’[email protected]$1$J$$$G$7$g$&$+!%e(B

e$B3NG’$7$^$7$?!#Bg>[email protected]$H;W$$$^$9!#e(B

e$B$=$l$G$b$^[email protected](B3Fe$B;D$C$F$^$9$M!ED4$Y$J$-$ce(B > test/drb

[email protected]$G$9!%e(B

Masatoshi SEKI wrote:

e$B=u$1$F$/[email protected]$5$$!#e(B
1.9e$B$Ne(BdRubye$B$Ne(Bretrye$B$N%F%9%H$G:$$C$F$$$^$9!#e(B

e$B!!JV;v$,CY$/$J$C$F:Q$_$^$;$s!J$&$o!$e([email protected](B…e$B!K!%e(B

e$B!!$^$:!$A0Ds$H$7$F!$e(BRuby 1.9 e$B$G$O%V%m%C%/Cf$K5-=R$9$ke(B retry
e$B$,$J$/$Je(B
e$B$j$^$7$?!%$3$l$O!$e(Bruby-core
[email protected]$G!$$^$D$b$H$5$s$,$=$&7h$ae(B
e$B$^$7$?!%e(B

e$B!!=>MhDL$j!$e(Brescue e$BCf$Ge(B retry e$B$9$k$HBP1~$9$ke(B begin
e$B$+$i;O$^$k5!G=$Oe(B
e$B;D$j$^$9!%e(B

e$B!!$D$^$j!$e(B

e$B!!e(B1.times{ retry } e$B$Oe(B SyntaxError

e$B!!e(Bbegin
raise
rescue
retry
end

e$B$O=>MhDL$j$H$J$j$^$9!%e(B

[email protected]$7!$e(B

begin
raise
rescue
1.times{ retry }
end

e$B$O!$=>Mh$Oe(B 1.times e$B$r$d$j$J$*$9;EAH$$G$7$?$,!$e(B1.9
e$B$N:#$N>uBV$G$Oe(B
e$B!Ve(BSyntaxErrore$B$K$J$j$^$9!W!%$3$NLdBj!J!)!K$O!$e(B1.9.2
e$B0J9
$Ge(B begin e$B$+$ie(B
e$B:F3+$9$k$h$&$K$J$k$+$b$7$l$^$;$s!%e(B

e$B!!$H$$$&$o$1$G!$$3$NLdBj$O2r7h$H$$$&$3$H$GNI$$$G$7$g$&$+!%e(B

e$B!!$A$J$$K!$:#F|$N%3%%C%H$Ge(B retry e$B$r:o$C$?$N$G$9$,!$e(Bdrb
e$B$Ne(B lib,
sample
e$B$N$[$&$GBP1~$9$k$H;W$o$l$k%3!<%I$r:o$i$;[email protected]$-$^$7$?!J%3e(B
e$B%s%Q%$%k;~$K%(%i!<$K$J$k$N$G!$;D$C$F$$$k$H%F%9%H$,DL$i$J$/$J$k!K!%$9e(B
e$B$_$^$;$s$,!$$43NG’[email protected]$1$J$$$G$7$g$&$+!%e(B

Index: lib/drb/invokemethod.rb

— lib/drb/invokemethod.rb (e$B%j%S%8%g%se(B 14322)
+++ lib/drb/invokemethod.rb (e$B:n6H%3%T!<e(B)
@@ -20,8 +20,6 @@ module DRb
end
if jump_error
case jump_error.reason

  •        when :retry
    
  •          retry
           when :break
             break(jump_error.exit_value)
           else
    

Index: test/drb/drbtest.rb

— test/drb/drbtest.rb (e$B%j%S%8%g%se(B 14322)
+++ test/drb/drbtest.rb (e$B:n6H%3%T!<e(B)
@@ -305,18 +305,19 @@ module DRbAry
assert_equal([1, 2, ‘III’, ‘III’, 4, ‘five’, 6], ary)
end

  • def test_04_retry
  • retried = false
  • ary = []
  • @there.each do |x|
  •  ary.push x
    
  •  if x == 4 && !retried
    
  • retried = true
  • retry
  •  end
    
  • end
  • assert_equal([1, 2, ‘III’, 4, 1, 2, ‘III’, 4, ‘five’, 6], ary)
  • end
  • retry in block is not supported on ruby 1.9

  • #def test_04_retry

  • retried = false

  • ary = []

  • @there.each do |x|

  • ary.push x

  • if x == 4 && !retried

  • retried = true

  • retry

  • end

  • end

  • assert_equal([1, 2, ‘III’, 4, 1, 2, ‘III’, 4, ‘five’, 6], ary)

  • #end

    def test_05_break
    ary = []

Index: sample/drb/darrayc.rb

— sample/drb/darrayc.rb (e$B%j%S%8%g%se(B 14322)
+++ sample/drb/darrayc.rb (e$B:n6H%3%T!<e(B)
@@ -45,15 +45,3 @@ ro.each do |x|
puts count
redo if count == 3
end

-puts “# each, retry”
-retried = false
-ro.each do |x|

  • puts x
  • if x == 4 && !retried
  • puts ‘retry’
  • retried = true
  • retry
  • end
    -end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs