On 2012-04-29 19:03, David Nadlinger wrote:

Yes, but that requires the compiler to generate the return value »glue«
code for continue/break inside an opApply foreach. If foreach is a
library function and you pass an ordinary delegate, you have a problem
in the current language since you can't know that a »return« statement
inside that delegate really should return from the outer function.

David

Yeah, that would need to be solved. In Ruby it works like this:

[1, 2, 3, 4].each do |i|
  if i == 2
    return
  end
end

Results in:

LocalJumpError: unexpected return

If you instead wrap it in method you can return from the each-block. So in Ruby it behaves just like having a "return" in a plain for-loop and not in a delegate. It would basically force a return in the "each" method.

--
/Jacob Carlborg

Reply via email to