From: matz@... (Yukihiro Matsumoto) Date: 2003-08-04T11:40:47+09:00 Subject: Re: Home grown continuations Hello, In message "Re: Home grown continuations" on 03/08/03, Jim Weirich writes: |> 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. It would be 1. Don't worry. It's not created with proc nor lambda. |> 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. It would be 1 again. It causes error when the call frame is lost. In your example, the method created a proc still running so that the call frame exists too. matz.