From: Jim Weirich Date: 2003-08-03T07:46:20+09:00 Subject: Re: Home grown continuations On Sat, 2003-08-02 at 12:02, Yukihiro Matsumoto wrote: > Since 1.8, return within the closures created by proc or lambda, just > terminates the closure execution. Huh? I'm not sure I am understanding. What should the following return? def x 10.times { |n| return 1 if n == 5 } 2 end p x I would expect 1, but you seem to be saying 2. > If you create a closure by > Proc.new, it causes error, since call frame information is already > lost unlike callcc. So Proc.new is different? What about the following code? def y p = Proc.new { |n| return 1 if n == 5 } 10.times(&p) 2 end Again, I would expect 1, but you seem to be saying it will be an error. BTW, both return 1 in an not-very-recent version of 1.8.0. (But that might be different in the previews). -- -- Jim Weirich jweirich@one.net http://onestepback.org ----------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)