Callcc, each and local val

e$B$3$s$P$s$O!"e(Bsheepman e$B$G$9!#e(B

trunk e$B$Ne(B callcc e$B$K4X$7$F$G$9!#e(B
Array#each e$B$N%V%m%C%/$NCf$Ge(B callcc
[email protected];~$N!"%m!<%+%kJQ?t$Ne(B
e$B;2>H$,$*$+$7$$$G$9!#e(B

$ cat t.rb
vv = 0
$c = 0
[1, 2, 3].each{|i|
callcc {|k| $k = k}
$c += 1
vv += 1
}
p [vv, $c]
$k.call if vv < 10 and $c < 10

$ ruby-1.8 -v t.rb
ruby 1.8.6 (2007-04-20 patchlevel 5000) [i686-linux]
[3, 3]
[4, 4]
[5, 5]
[6, 6]
[7, 7]
[8, 8]
[9, 9]
[10, 10]

$ ruby-1.9 -v t.rb
ruby 1.9.0 (2007-05-29 patchlevel 0) [i686-linux]
[3, 3]
[3, 4]
[3, 5]
[3, 6]
[3, 7]
[3, 8]
[3, 9]
[3, 10]

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

[email protected]$K5$IU$$$F$/$l$kJ}$,$$$FBgJQ4n$s$G$$$^$9!#e(B

e$B!!$^$:!"7QB3$,%-%c%W%A%c$9$kBP>]$G$9$,!"e(B1.9
e$B$N<BAu$G$O$9$Y$F$Ne(B
e$B%m!<%+%kJQ?t$rJ]B8$9$k$3$H$G<B8=$7$F$$$^$9!#e(B1.8
e$B$G$O!"7QB3$G$Oe(B
e$B%m!<%+%kJQ?t$OJ]B8$7$F$$$^$;$s$G$7$?!#e(B

e$B!!$I$&$9$k$Y$-$J$s$G$7$g$&$+!#7QB3$O!V$3$&$G$J$1$l$P$J$i$J$$!We(B
e$B$H$$$&$N$O!"$h$/$o$+$C$F$$$^$;$s!#C/$+!"[email protected]$+$i!A$G$"$k$Y$-e(B
[email protected]!W$H$$$&OC$r$7$F$b$i$($J$$$G$7$g$&$+!#e(B

e$B!!e(BScheme e$B$N>l9g$G$9$H!"e(B

(let ((v #f))
(call/cc (lambda ©
(set! v #t)
(c #t)))
(print v)) ;=> #t

e$B$H$J$j!"%m!<%+%kJQ?t$,JQ99$5$l$F$$$k$3$H$,$o$+$j$^$9!#e(B1.8 e$B0Je(B
e$BA0!"$*$h$Se(B Scheme e$B$J$I$H$"$o$;$k$Y$-$G$7$g$&$+!#e(B

e$B!!<BAu%l%Y%k$NOC$r$9$k$H!"e(BVMe$B%9%?%C%/$r4JC1$K%3%T!<[email protected]$1$G$9e(B
e$B$N$G!"J]B8$7$F$$$J$$$H$$$&$3$H$G$9!#e(B

e$B!!<B$O!"<+J,$be(B

cont = nil
callcc{|c| cont = c
}
cont.call

e$B$H$$$&%3!<%I$,F0$+$:!">/$7G:$s$G$7$^$$$^$7$?!#e(B

e$B!!$A$g$C$H!"<BAuJ}K!$,$&$^$$$3$H;W$$Ib$+$P$J$+$C$?$s$G$9$,!“3Fe(B
e$B%9%3!<%W$Ge(B binding
e$BAjEv$r$d$k$h$&$K$9$l$P=PMh$k$N$+$J$!!”$H$Oe(B
e$B;W$$$^$9!#e(B

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

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

e$B!!BP1~$,$9$0$K=PMh$=$&[email protected]$C$?$N$G!"$=$N$h$&$J<BAu$K$7$^$7$?!#e(B

Yukihiro M. e$B$5$s$O=q$-$^$7$?e(B:

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

In message “Re: [ruby-dev:30834] Re: callcc, each and local val”
on Wed, 30 May 2007 03:31:26 +0900, SASADA Koichi [email protected]
writes:

|(let ((v #f))
| (call/cc (lambda ©
| (set! v #t)
| (c #t)))
| (print v)) ;=> #t
|
|e$B$H$J$j!"%m!<%+%kJQ?t$,JQ99$5$l$F$$$k$3$H$,$o$+$j$^$9!#e(B1.8 e$B0Je(B
|e$BA0!"$*$h$Se(B Scheme e$B$J$I$H$"$o$;$k$Y$-$G$7$g$&$+!#e(B

e$B8D?ME*$K$O$=$N$h$&$J5sF0$r4|BT$7$^$9!#e(B

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

In message “Re: [ruby-dev:30841] Re: callcc, each and local val”
on Wed, 30 May 2007 14:58:43 +0900, SASADA Koichi [email protected]
writes:

|e$B!!BP1~$,$9$0$K=PMh$=$&[email protected]$C$?$N$G!"$=$N$h$&$J<BAu$K$7$^$7$?!#e(B

e$B$"$j$,$H$&$4$6$$$^$9!#e(B

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