Return from proc in lambda

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

def m
lambda{
proc{
return :ng1
}
}.call.call
:ng2
end

begin
m()
rescue LocalJumpError
:ok
end

e$B!!$3$NNc$G$9$,!$e(BLocalJumpError
e$B$K$9$k$Y$-$+$J!$$H;W$&$N$G$9$,!$$I$&e(B
e$B$G$7$g$&$+!%e(B1.8, 1.9 e$B$H$b$Ke(B :ng2 e$B$,JV$j$^$9!%e(B1.9.0-2
e$B$G$O!$e(Bpending
e$B$K$7$?$$$H;W$$$^$9!%e(B

In message “Re: [ruby-dev:35167] return from proc in lambda”
on Thu, 19 Jun 2008 11:39:24 +0900, SASADA Koichi [email protected]
writes:
|
|[email protected]$G$9!%e(B
|
| def m
| lambda{
| proc{
| return :ng1
| }
| }.call.call
| :ng2
| end
|
| begin
| m()
| rescue LocalJumpError
| :ok
| end
|
|e$B!!$3$NNc$G$9$,!$e(BLocalJumpError e$B$K$9$k$Y$-$+$J!$$H;W$&$N$G$9$,!$$I$&e(B
|e$B$G$7$g$&$+!%e(B1.8, 1.9 e$B$H$b$Ke(B :ng2 e$B$,JV$j$^$9!%e(B1.9.0-2 e$B$G$O!$e(Bpending
|e$B$K$7$?$$$H;W$$$^$9!%e(B

[ruby-dev:35171]e$B$K=q$$$?86B’$K=>$($P!"e(B:ng1e$B$,JV$k$O$:$G$9!#e(B
e$B$^[email protected](Bme$B$N<B9T$,40N;$7$F$$$J$$0J>e!"e(Bproce$B$+$i$Ne(Breturne$B$Oe(Bme$B$r=*N;$5e(B
e$B$;$k$O$:$G$9!#e(B

e$B$,!"JL$K$3$l$,@dBP$H;W$C$F$$$k$o$1$G$O$J$$$N$G!“e(Blambdae$B$r$^$?e(B
[email protected](Bproce$B$+$i$Ne(Breturne$B$O6X;_e(B(LocalJumpError)e$B!”$G$bA4A39=$o$J$$e(B
e$B$H;W$$$^$9!#e(B

[email protected]!"e(Bng2e$B$rJV$9e(B([email protected]$1$r=*$o$i$;$k!)e(B)e$B$N$O%J%$$H;W$$$^$9!#e(B
1.8e$B$NJ}$b$3$l$G7h$a$?7k2L$K9g$o$;$FD>$7$^$9!#e(B

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

Yukihiro M. wrote:

[ruby-dev:35171]e$B$K=q$$$?86B’$K=>$($P!"e(B:ng1e$B$,JV$k$O$:$G$9!#e(B
e$B$^[email protected](Bme$B$N<B9T$,40N;$7$F$$$J$$0J>e!"e(Bproce$B$+$i$Ne(Breturne$B$Oe(Bme$B$r=*N;$5e(B
e$B$;$k$O$:$G$9!#e(B

e$B$,!"JL$K$3$l$,@dBP$H;W$C$F$$$k$o$1$G$O$J$$$N$G!“e(Blambdae$B$r$^$?e(B
[email protected](Bproce$B$+$i$Ne(Breturne$B$O6X;_e(B(LocalJumpError)e$B!”$G$bA4A39=$o$J$$e(B
e$B$H;W$$$^$9!#e(B

e$B!!$^$:D{@5$G$9$,!$e(B1.9 e$B$G$Oe(B :ng1 e$B$rJV$7$F$^$7$?!%e(B

e$B!!e(B1.9 e$B$G$O!$e(Blambda
e$B$r!V%a%=%C%I8F$S=P$7!W$C$]$/07$&!$$H$$$&86B’$,e(B
e$B$"$C$?$O$:$G$9!%$J$N$G!$e(Blambda{return}.call e$B$O!$e(Blabmda
e$B$rH4$1$k$h$&e(B
e$B$K$J$C$F$$$^$9!%e(B

e$B!!$5$F!$$3$3$Ge(B lambda e$B$+$i8+$Fe(B orphan e$B$Je(B proc
e$B$r$I$&07$&$Y$-$+!$$H$$e(B
e$B$&LdBj$,=P$F$-$?$N$G!$!Ve(BLocalJumpError
e$B$K$9$k$Y$-$+!)!W!$$H$$$&5?Lde(B
e$B$,=P$F$-$?$o$1$G$9!%e(B

e$B!!e(B1.9 e$B$G$O!$e(Bdefine_method e$B$7$?%V%m%C%/$O!$e(Blambda
e$B$N8F$S=P$7$H$[$\F1e(B
e$B$8$G$9!%$J$N$G!$e(Bdefine_method e$B$GDj5A$7$?%a%=%C%I$+$i8+$Fe(B
orphan e$B$Je(B
proc e$B$+$i$Ne(B return
e$B!$$H8+$k$H!Ve(BLocalJumpErrore$B!W$H8+$k$3$H$,=PMh$k$+e(B
e$B$J!$$H;W$C$F$*$j$^$9!%e(B

e$B!!<BAuE*$JET9g$G$$$&$H!$!Ve(Blambda e$B$+$i8+$Fe(B orphan
e$B$r%A%’%C%/$9$k$NBge(B
e$BJQ$=$&[email protected]$J$!!W$H;W$C$F!$BP1~=PMh$F$$$^$;$s!%[email protected]!$e(Bm()
e$B$+$iH4$1$k$Ue(B
e$B$D!<$Ne(B return
e$B$K$J$C$F$$$^$9!%$A$g$C$H!$%l%"%1!<%92a$.$k$+$J$"!$$H$be(B
e$B;W$&$N$G!$BP1~$7$J$/$F$b!$FC$K:$$i$J$$$+$H$O;W$$$^$9!%e(B

e$B$^$D$b$He(B e$B$f$-$R$m$G$9e(B

In message “Re: [ruby-dev:35173] Re: return from proc in lambda”
on Thu, 19 Jun 2008 12:33:01 +0900, SASADA Koichi [email protected]
writes:

|e$B!!e(B1.9 e$B$G$O!$e(Blambda e$B$r!V%a%=%C%I8F$S=P$7!W$C$]$/07$&!$$H$$$&86B’$,e(B
|e$B$"$C$?$O$:$G$9!%$J$N$G!$e(Blambda{return}.call e$B$O!$e(Blabmda e$B$rH4$1$k$h$&e(B
|e$B$K$J$C$F$$$^$9!%e(B

e$B$=$&$G$9$h$M!#5$$K$J$k$N$Oe(B

def m
p lambda{proc{return :r1}.call; :r2}.call
:r3
end
p m

e$B$,!"$J$K$r=PNO$9$k$+$G$9$,!"e(B1.9e$B$G$Oe(B

:r1
:r3

1.8e$B$G$Oe(B

:r2
:r3

e$B$rJV$7$^$9$M!#$3$l$O!Ve(B1.9e$B$NJ}$,@5$7$$!W$H$$$&$3$H$K$7$^$7$ge(B
e$B$&!#e(B1.8e$B$rD>$9$+$I$&$+$O$^[email protected]$o$+$j$^$;$s$,!#e(B

|e$B!!$5$F!$$3$3$Ge(B lambda e$B$+$i8+$Fe(B orphan e$B$Je(B proc e$B$r$I$&07$&$Y$-$+!$$H$$e(B
|e$B$&LdBj$,=P$F$-$?$N$G!$!Ve(BLocalJumpError e$B$K$9$k$Y$-$+!)!W!$$H$$$&5?Lde(B
|e$B$,=P$F$-$?$o$1$G$9!%e(B

e$B$=$&$G$9$M!#@hDx$N%a!<%ke(B[ruby-dev:35172]e$B$G$O!“e(B:ng1e$B$rJV$9$H=qe(B
e$B$-$^$7$?$,!”$3$l$,e(Blambdae$B$NCf$G$"$j!"e(Breturne$B$NBP>]$OK\Mhe(Bme$B$G$Je(B
e$B$/!“e(Blambdae$B$G$”$k$3$H$r9M$($k$H!"e(B:ng1e$B$h$j$be(BLocalJumpErrore$B$G$"e(B
[email protected]$H;W$&$h$&$K$J$j$^$7$?!#$4$a$s!#e(B

e$B$G!"$D$$$5$C$-$^$Ge(BLocalJumpErrore$B$rJV$7$F$$$?$h$&$J$N$K!“e(B:ng1
e$B$rJV$9$h$&$K$J$j$^$7$?$M!#$H$$$&$3$H$O!”[email protected]$5$s$KL5BL$J:ne(B
e$B6H$r6/MW$5$;$F$7$^$$$^$7$?$G$7$g$&$+!#e(B

                            e$B$^$D$b$He(B e$B$f$-$R$me(B /:|)