retry$B$N;H$$J}(B


#1

e$B>>Hx$H$$$$$^$9!#e(B

e$B%f!<%6Dj5A$Ne(B “untile$B%k!<%We(B”

def UNTIL(cond)
return if cond
yield
retry
end

e$B$3$N$h$&$Je(Bretrye$B$N;H$$J}$,e(B1.86e$B$G$ODL$k$s$G$9$,!"e(B
1.9e$B$@$H%a%=%C%IDj5A$r$7$?CJ3,$Ge(B
SyntaxError: Illegal retry
e$B$H$J$j$^$9!#e(B

e$B$3$l$Oe(Bretrye$B$N;EMMJQ99$G$9$+!)$b$7$=$&$@$H$7$?$i!"e(B
e$B>e$N$h$&$J%3!<%I$K$O=$@5$,I,MW$G$9$+!)e(B

e$BNc$Oe(BRubye$B%j%U%!%l%s%9%^%K%e%"%k$+$i;}$C$F$-$^$7$?!#e(B

ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-mswin32]
ruby 1.9.0 (2007-07-24 patchlevel 0) [i386-mswin32_80]


#2

e$B!!$5$5$@$G$9!#e(B

eklerni wrote:

e$B$H$J$j$^$9!#e(B

e$B$3$l$Oe(Bretrye$B$N;EMMJQ99$G$9$+!)$b$7$=$&$@$H$7$?$i!"e(B
e$B>e$N$h$&$J%3!<%I$K$O=$@5$,I,MW$G$9$+!)e(B

e$BNc$Oe(BRubye$B%j%U%!%l%s%9%^%K%e%"%k$+$i;}$C$F$-$^$7$?!#e(B

ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-mswin32]
ruby 1.9.0 (2007-07-24 patchlevel 0) [i386-mswin32_80]

e$B!!$3$Ne(B retry e$B$N;H$$J}$OCN$i$J$+$C$?!#$N$G!"<BAu=PMh$F$$$^$;e(B
e$B$s!#$I$&$7$?$b$s$G$7$g$&!#e(B

e$B!!e(Brescue/ensure e$B$b$7$/$Oe(B block
e$B$NCf$K$7$+CV$1$J$$$H;W$C$F$^$7$?!#e(B


#3

e$B>>Hx$G$9!“JV?.$”$j$,$H$&$4$6$$$^$9!#e(B

SASADA Koichi e$B$5$s$O=q$-$^$7$?e(B:

e$B!!$5$5$@$G$9!#e(B
e$B!!$3$Ne(B retry e$B$N;H$$J}$OCN$i$J$+$C$?!#$N$G!"<BAu=PMh$F$$$^$;e(B
e$B$s!#$I$&$7$?$b$s$G$7$g$&!#e(B

e$B!!e(Brescue/ensure e$B$b$7$/$Oe(B block e$B$NCf$K$7$+CV$1$J$$$H;W$C$F$^$7$?!#e(B

1.8e$B$G$Oe(Bblocke$B$^$?$Oe(Bproce$B%*%V%8%’%/%H$D$-$G8F$S=P$7$?$i!Je(Bblocke$BFb$Ge(Bretrye$B$7$?e(B
e$B$H$-$HF1$8$h$&$K!KF0$/$h$&$G$9$M!#e(B

def foo
retry
end

foo #=>retry outside of rescue clause (LocalJumpError)
foo{} #=>e$BL58B%k!<%We(B
foo(&proc{}) #=>e$BL58B%k!<%We(B
foo(&lambda{}) #=>e$BL58B%k!<%We(B

retrye$B$J$7$G%f!<%6!<Dj5A%k!<%W$r!Je(Bwhilee$B$H$+$J$7$G!K:n$k$N$O87$7$$$s$G!"I,e(B
e$BMW$J5!G=$@$H$O;W$$$^$9!#e(B

e$B$"$He(Bensuree$B$N$J$+$Ge(Bretrye$B$C$F;H$($k$b$N$G$7$?$C$1!)e(B1.8e$B$He(B1.9e$B$I$C$A$b%@%a$=e(B
e$B$&$G$9$1$I!#e(B

begin
ensure
retry
end

1.9 => retry outside of rescue clause
1.86 => legal retrye$B!!e(Bcompile error (SyntaxError)

ruby 1.8.6 (2007-06-07 patchlevel 36) [i386-mswin32]
ruby 1.9.0 (2007-07-24 patchlevel 0) [i386-mswin32_80]


#4

e$B!!$5$5$@$G$9!#e(B

eklerni wrote:

e$B$"$He(Bensuree$B$N$J$+$Ge(Bretrye$B$C$F;H$($k$b$N$G$7$?$C$1!)e(B1.8e$B$He(B1.9e$B$I$C$A$b%@%a$=e(B
e$B$&$G$9$1$I!#e(B

e$B!!e(Bensure e$B$O4*0c$$$G$7$?!#e(B


#5

In article removed_email_address@domain.invalid,
eklerni removed_email_address@domain.invalid writes:

retrye$B$J$7$G%f!<%6!<Dj5A%k!<%W$r!Je(Bwhilee$B$H$+$J$7$G!K:n$k$N$O87$7$$$s$G!"I,e(B
e$BMW$J5!G=$@$H$O;W$$$^$9!#e(B

e$B<B:]$K$O$I$N$h$&$J%f!<%6!<Dj5A%k!<%W$r:n$j$?$$$s$G$7$g$&e(B?

e$BIaDL$N%$%F%l!<%?$G$O$&$^$/$$$+$J$$$s$G$7$g$&$+!#e(B


#6

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

07/07/26 e$B$Ke(B eklerniremoved_email_address@domain.invalid
e$B$5$s$O=q$-$^$7$?e(B:

e$B$H$-$HF1$8$h$&$K!KF0$/$h$&$G$9$M!#e(B
e$BCN$j$^$;$s$G$7$?!#6C$-$G$9!#e(B
e$B$7$+$7!"$3$Ne(Bretrye$B$,$"$jF@$k$J$i%"%J%m%8!<$Ge(BProc#retrye$B$,M_$7$/$J$j$^$;$s$+!#e(B


#7

In article removed_email_address@domain.invalid,
Yugui removed_email_address@domain.invalid writes:

e$BCN$j$^$;$s$G$7$?!#6C$-$G$9!#e(B
e$B$7$+$7!"$3$Ne(Bretrye$B$,$"$jF@$k$J$i%"%J%m%8!<$Ge(BProc#retrye$B$,M_$7$/$J$j$^$;$s$+!#e(B

e$B$=$l$O$I$N$h$&$JMQES$K$*$$$FLr$KN)$A$^$9$+e(B?


#8

e$B>>Hx$H$$$$$^$9!#e(B

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:
e$B<B:]$K$O$I$N$h$&$J%f!<%6!<Dj5A%k!<%W$r:n$j$?$$$s$G$7$g$&e(B?

e$BIaDL$N%$%F%l!<%?$G$O$&$^$/$$$+$J$$$s$G$7$g$&$+!#e(B
e$BA02s$N$Oe(Bwhilee$B$r;H$o$:$Ke(Bwhilee$B$rDj5A$9$k$K$Oe(Bretrye$B$,I,MW!"$H$$$&MW;]$NH/8@e(B
e$B$G$9$,!“e(B
e$B<B:]$Ke(Bretrye$B$,$”$C$?$[$&$,$&$l$7$$>lLL$r9M$($F$_$k$H!"$?$H$($Pe(B

def foo
while e$B>r7oe(B
yield #e$B%k!<%WK\BNe(B(Y)
end
#e$B$J$s$i$+$N=hM}e(B(A)
end

e$B$$?$$$J%a%=%C%I$r=q$$$?$H$-$K!"e(Byielde$B$He(Byielde$B$N4V$He(B#e$B$J$s$i$+$N=hM}e(B(A)e$B$N8e$Ge(B
e$B6&DL$Ne(B#e$B8e=hM}e(B(B)e$B$r$7$?$$$H$7$^$9!#e(B(Y)(B)…(Y)(B)(Y)(A)(B)e$B$
$?$$$K!#$9$k$He(B

def foo
while e$B>r7oe(B
#e$B8e=hM}e(B if e$BFs2sL$N%k!<%W$+$ie(Btruee$B$K$J$k%U%i%C%0e(B
yield
end
#e$B$J$s$i$+$N=hM}e(B
#e$B8e=hM}e(B
end

e$B$_$?$$$K$J$C$F!"e(B#e$B8e=hM}$N%3!<%I$,J,$+$l$A$c$&$s$G$9$,!"e(Bretrye$B$r;H$($Pe(B

def foo
yield
retry if e$B>r7oe(B
#e$B$J$s$i$+$N=hM}e(B
ensure
#e$B8e=hM}e(B
end

e$B$H%m%8%C%/$,$9$C$-$j$9$k>lLL$b$"$j$^$9!#e(B

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

e$BCN$j$^$;$s$G$7$?!#6C$-$G$9!#e(B
e$B$7$+$7!"$3$Ne(Bretrye$B$,$"$jF@$k$J$i%"%J%m%8!<$Ge(BProc#retrye$B$,M_$7$/$J$j$^$;e(B
e$B$s$+!#e(B
e$B$I$3$KLa$k$N$+$o$+$i$J$/$J$j$=$&$G$9$M!#$G$be(B
e$BL5L>4X?t$H$7$F?6Iq$&$3$H$,4|BT$5$l$F$$$ke(Blambdae$B$K$OM_$7$$$+$J!"$H;W$$$^$9!#e(B

e$B$"$H$5$5$@$5$s$X!#e(Blambdae$B$K$D$$$F$G$9$,!"e(B

def foo &po
lambda(&po).call
e$B!!e(Bp :methodend
end

foo{return} #1.9#unexpected return (LocalJumpError) #1.8#=>:methodend
foo(&proc{return}) #1.9#unexpected return (LocalJumpError)
#1.8#=>:methodend

1.8e$B$@$H$I$A$i$be(Bnexte$B$N$h$&$KF/$-$^$9$,!“e(B1.9e$B$@$He(Bunexpected
return
(LocalJumpError)e$B$K$J$j$^$9!#e(B
lambdae$B$N5sF0$H$7$F$Oe(B1.8e$B$N$h$&$K%V%m%C%/$rH4$1$k$[$&$r4|BT$7$A$c$&$s$G$9e(B
e$B$,!”$I$&$G$7$g$&!)e(B


#9

In article removed_email_address@domain.invalid,
eklerni removed_email_address@domain.invalid writes:

e$BA02s$N$Oe(Bwhilee$B$r;H$o$:$Ke(Bwhilee$B$rDj5A$9$k$K$Oe(Bretrye$B$,I,MW!"$H$$$&MW;]$NH/8@e(B
e$B$G$9$,!"e(B

e$B$G$b!“e(Bwhile e$B$O<B:]$K$”$k$s$G$9$+$i!“e(Bwhile
e$B$r%f!<%6$,Dj5A$9$ke(B
e$BI,MW$O$”$j$^$;$s!#85$+$i$"$ke(B while e$B$r;H$($P$$$$$s$G$9!#e(B

e$B$D$^$je(B while e$B$=$l<+BN$O!"%f!<%6$,Dj5A$G$-$?$+$i$C$F<B:]$N%We(B
e$B%m%0%i%_%s%0$GLr$KN)$D$o$1$G$O$J$$$s$G$9!#e(B

e$B$J$N$G!"e(Bwhile e$B$G$O$J$$0[$J$k$b$N$rDj5A$9$k$N$Ke(B retry
e$B$,M_$7e(B
e$B$/$J$kNc$r?R$M$5$;$F$$$?$@$-$^$7$?!#e(B

e$B$G!"$=$NNc$G$9$,!"e(B

e$B6&DL$Ne(B#e$B8e=hM}e(B(B)e$B$r$7$?$$$H$7$^$9!#e(B(Y)(B)…(Y)(B)(Y)(A)(B)e$B$$?$$$K!#$9$k$He(B
e$B$
$?$$$K$J$C$F!"e(B#e$B8e=hM}$N%3!<%I$,J,$+$l$A$c$&$s$G$9$,!"e(Bretrye$B$r;H$($Pe(B

def foo
yield
retry if e$B>r7oe(B
#e$B$J$s$i$+$N=hM}e(B
ensure
#e$B8e=hM}e(B
end

e$B$H%m%8%C%/$,$9$C$-$j$9$k>lLL$b$"$j$^$9!#e(B

foo e$B$K$O0z?t$,$J$$$N$G!“e(Bretry e$B$N4qL/$JE@$G$”$k$H$3$m$N<B0z?te(B
e$B$NI>2A$+$i:F3+$5$l$k!"$H$$$&ItJ,$,;H$o$l$F$$$^$;$s$,!"<B0z?te(B
e$B$,:FI>2A$5$l$k$3$H$OITMW$G$9$+e(B?


#10

e$B$J$+$@$G$9!#e(B

At Fri, 27 Jul 2007 00:17:03 +0900,
Tanaka A. wrote in [ruby-dev:31305]:

In article removed_email_address@domain.invalid,
Yugui removed_email_address@domain.invalid writes:

e$BCN$j$^$;$s$G$7$?!#6C$-$G$9!#e(B
e$B$7$+$7!"$3$Ne(Bretrye$B$,$"$jF@$k$J$i%"%J%m%8!<$Ge(BProc#retrye$B$,M_$7$/$J$j$^$;$s$+!#e(B

e$B$=$l$O$I$N$h$&$JMQES$K$*$$$FLr$KN)$A$^$9$+e(B?

e$B$I$&$$$&$H$-$KLr$KN)$D$+0JA0$K!"e(Bcalle$B$9$kA0$K0lBN$I$3$+$i!V:F3+!We(B
e$B$9$k$N$+A[A|$G$-$^$;$s!#e(B


#11

In article removed_email_address@domain.invalid,
eklerni removed_email_address@domain.invalid writes:

big = 0
Thread.new{loop{sleep 0.7;big += 1}} #big e$B$N;~4VJQ2=e(B

def foo(n)
sleep(1)
yield n
retry
end

foo(big){|n|p n} #=>1,2,4,5,…

e$B$=$l$J$ie(B retry e$B$r;H$o$J$/$F$b%V%m%C%/$NCf$Ge(B big
e$B$r;2>H$9$l$Pe(B
e$B$$$$$N$G$O$"$j$^$;$s$+e(B?

% ruby -e ’
big = 0
Thread.new{loop{sleep 0.7;big += 1}}

def foo
while true
sleep 1
yield
end
end

foo { p big }

1
2
4
5
7

e$B%a%=%C%I$N0z?t$NI>2A$+$i$d$jD>$9e(B retry e$B$,Lr$KN)$D$H;W$($kNce(B
e$B$O$J$$$s$G$7$g$&$+!#e(B


#12

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:

e$B$=$l$J$ie(B retry e$B$r;H$o$J$/$F$b%V%m%C%/$NCf$Ge(B big e$B$r;2>H$9$l$Pe(B
e$B$$$$$N$G$O$"$j$^$;$s$+e(B?

e$B$"$"$=$N$H$&$j$G$9$M!“Nc$K$J$C$F$J$$!#$=$l$8$c$”;vA0$Ke(B(e$BJQ?tL>$,e(Bbige$B$@$H7he(B
e$B$^$k$h$j$bA0$Ke(B)proce$B%*%V%8%’%/%H$re(B
e$B:n@.$7$F!"$=$l$rMQ$$$?$$>u67$@$C$?$i$I$&$G$9$+!)e(B

it = proc{|n| p n }
big = 0
Thread.new{loop{sleep 0.7;big += 1}}

def foo(n)
sleep(1)
yield n
retry
end

foo(big,&it)

e$B%/%i%92=$7$F%$%s%9%?%s%9JQ?t$r;H$C$?$j!"e(Bproce$B:n@.A0$Ke(Bbig=0e$B$r$O$5$s$@$j$9e(B
e$B$l$P$$$1$^$9$,!"e(B
e$B$=$&$$$&$N$r$7$?$/$J$$>u67$C$F$3$H$Ge(B:-)

ruby 1.8.6 (2007-07-28 patchlevel 5000) [i386-mswin32_80]


#13

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:

foo e$B$K$O0z?t$,$J$$$N$G!“e(Bretry e$B$N4qL/$JE@$G$”$k$H$3$m$N<B0z?te(B
e$B$NI>2A$+$i:F3+$5$l$k!"$H$$$&ItJ,$,;H$o$l$F$$$^$;$s$,!"<B0z?te(B
e$B$,:FI>2A$5$l$k$3$H$OITMW$G$9$+e(B?
e$B?M9)E*$JNc$G$9$,!"e(B

e$B!V<hF@$9$k$?$S$KCM$NJQ$o$C$F$$$/%m!<%+%kJQ?te(B(big)e$B$r0z?t$K$H$j!"0lIC4V3Ve(B
e$B$G$=$NJQ?t$r;H$C$Fe(B
e$B$J$s$+$9$k%a%=%C%Ie(B(foo)e$B$r$D$/$j$?$$$H$9$k!#$?$@$7%a%=%C%IDj5AFbIt!J$H<Be(B
e$B0z?tIt!K$KD>@\JQ?tL>e(Bbige$B$r=q$-9~$`$h$&$Je(B
e$B$3$H$O$7$?$/$J$$!#!We(B

retrye$B$r;H$&$H$3$s$J46$8$K$J$j$^$9!#"-e(B

big = 0
Thread.new{loop{sleep 0.7;big += 1}} #big e$B$N;~4VJQ2=e(B

def foo(n)
sleep(1)
yield n
retry
end

foo(big){|n|p n} #=>1,2,4,5,…


#14

e$B>>Hx$G$9!#e(B

Tanaka A. e$B$5$s$O=q$-$^$7$?e(B:

e$B$?$s$Ke(B it e$B$r8F$V%V%m%C%/$re(B foo e$B$K$D$1$l$P$$$$$N$G$Oe(B?

e$B$J$s$+?’!94*0c$$$7$F$^$7$?!"$9$_$^$;$s!#$=$NDL$j$G$9$M!#e(B
e$B$"$H%G%U%)%k%H0z?t$NMm$`>l9g$r=q$3$&$H$7$?$s$G$9$,!"e(B1.9e$B$Ne(Blambdae$B$C$Fe(B
e$B$=$l$b;XDj$G$-$k$h$&$K$J$C$?$s$G$9$M!#e(B

e$B7kO@$7$F$O!";d$Oe(Bretrye$B$Oe(Bensuree$B$GJdB-$G$-$k$N$O4r$7$$>lLL$,$"$k$+$J$!$H$Oe(B
e$B;W$$$^$9$,!"e(B
e$B0z?t$r:FI>2A$9$k@-<A$K$D$$$F$OFC$KM-MQ$J>lLL$O;W$$$D$-$^$;$s!#e(B


#15

In article removed_email_address@domain.invalid,
eklerni removed_email_address@domain.invalid writes:

yield n
retry
end

foo(big,&it)

e$B%/%i%92=$7$F%$%s%9%?%s%9JQ?t$r;H$C$?$j!"e(Bproce$B:n@.A0$Ke(Bbig=0e$B$r$O$5$s$@$j$9e(B
e$B$l$P$$$1$^$9$,!"e(B
e$B$=$&$$$&$N$r$7$?$/$J$$>u67$C$F$3$H$Ge(B:-)

e$B$?$s$Ke(B it e$B$r8F$V%V%m%C%/$re(B foo e$B$K$D$1$l$P$$$$$N$G$Oe(B?

it = proc{|n| p n }
big = 0
Thread.new{loop{sleep 0.7;big += 1}}

def foo
while true
sleep 1
yield
end
end

foo{it.call(big)}


#16

From:eklerni

e$B!!$9$_$^$;$s!"!V4r$7$$>lLL!W$,$h$/$o$+$C$F$$$J$$$N$G$9$,!"65$($F$$$?e(B
e$B$@$1$^$;$s$+!#e(B

e$B!!$G!"$3$NJU$I$&$7$^$7$g$&!d$^$D$b$H$5$se(B

[ruby-dev:31306] e$B$N$h$&$J>l9g$G$9!#$?$@!"8_49@-$NLdBj$r=|$1$P!"e(B
e$BJL$K$J$/$J$C$F$b:$$i$J$$$H$O;W$$$^$9!#e(B


#17

e$B!!$5$5$@$G$9!#e(B

eklerni wrote:

e$B7kO@$7$F$O!";d$Oe(Bretrye$B$Oe(Bensuree$B$GJdB-$G$-$k$N$O4r$7$$>lLL$,$"$k$+$J$!$H$Oe(B
e$B;W$$$^$9$,!"e(B
e$B0z?t$r:FI>2A$9$k@-<A$K$D$$$F$OFC$KM-MQ$J>lLL$O;W$$$D$-$^$;$s!#e(B

e$B!!$9$_$^$;$s!"!V4r$7$$>lLL!W$,$h$/$o$+$C$F$$$J$$$N$G$9$,!"65$($F$$$?e(B
e$B$@$1$^$;$s$+!#e(B

e$B!!$G!"$3$NJU$I$&$7$^$7$g$&!d$^$D$b$H$5$se(B


#18

From:eklerni

end

e$B$G$$$$$h$&$J5$$,$9$k$J$!!#e(B

e$BF0$+$J$$$s$G$9$1$I!"e(B
def foo
begin
begin
yield

e$B2?$i$+$N=hM}e(B

end while e$B>r7oe(B
ensure

e$B8e=hM}e(B

end
end

e$B$G$9$+$M!)$3$NNc$N>l9g$O%k!<%W$NEY$Ke(Bensuree$B$G8e=hM}$7$?$$$s$G!"Bg0hC&=P$7e(B
e$B$J$$e(Bwhilee$B$@$He(B
e$BBj0U$OK~$?$5$J$$$H;W$$$^$9!#e(B


#19

e$B!!$5$5$@$G$9!#e(B

eklerni wrote:

[ruby-dev:31306] e$B$N$h$&$J>l9g$G$9!#$?$@!"8_49@-$NLdBj$r=|$1$P!"e(B
e$BJL$K$J$/$J$C$F$b:$$i$J$$$H$O;W$$$^$9!#e(B

def foo
yield
retry if e$B>r7oe(B
#e$B$J$s$i$+$N=hM}e(B
ensure
#e$B8e=hM}e(B
end

e$B$H%m%8%C%/$,$9$C$-$j$9$k>lLL$b$"$j$^$9!#e(B

e$B!!$3$NNc$@$H$9$k$H!"e(B

def foo
begin
yield
# e$B2?$i$+$N=hM}e(B
end while e$B>r7oe(B
ensure
# e$B8e=hM}e(B
end
end

e$B$G$$$$$h$&$J5$$,$9$k$J$!!#e(B


#20

From:eklerni

end

e$B!!$3$s$J$s$G$I$&$G$7$g$&$+!#e(B

A()# e$B2?$i$+$N=hM}e(B
B()# e$B8e=hM}e(B
e$B$G$9$+!)e(B
e$B85$NNc$Oe(B

(yield->e$B8e=hM}e(B->yield->e$B8e=hM}e(B->…)->e$B2?$i$+$N=hM}e(B->e$B8e=hM}e(B
e$B$H$$$&%U%m!<$r8e=hM}$N%3!<%I$r0l2U=j$K$^$H$a$k>r7o$G9T$$$?$$$N$G$9$,!"e(B
e$B!Je(B()e$B$OG$0U$N%k!<%W!Ke(B

e$B$3$NBe0F$@$He(B
(yield->A()e$B2?$i$+$N=hM}e(B->B()e$B8e=hM}e(B->…)->yield->B()e$B8e=hM}e(B

e$B$K$J$C$A$c$C$F$^$9e(B^^;

#e$B$$$C$?$s?2$^$9!"$*$d$9$_$J$5$$!#e(B