I played lately a bit with Groovy and was surprised to see that it doesn't support non-local returns from inside a closure. I was quite surprised by this, because I always expected this to be the normal case from the time developing with Smalltalk. JDK8 lambdas also don't support non-local returns as I figured out to my despair. Happily, Scala does.
The question Are non-local returns from inside a closure a must for a closure implementation to be "full-fledged"? Or am I just used to it from Smalltalk, but that needn't be the case.
Code illustration
def list = list(1, 2, 3)
def value = list.forEach { each ->
println(each)
if(true)
return each
return 5
}
println(value)
I expect it to print "11" and not "1235". At least it shouldn't compile if it would print "1235".