On 04.12.24 18:03, OCsite wrote: [...]
A trivial (and most probably very very wrong and problems-inducing!) approach might perhaps be an ASTT which would convert code likedef foo() { bar.each { if (it) methodreturn it } } to something like def foo() { try { bar.each { if (it) throw new MethodReturnException(value:it) } } catch (MethodReturnException e) { return e.value } }
just to give a short extract of the trouble... 1) Who guarantees that the Closure executed by each is actually executed by it and when? 2) If you have Closure in Closure with method return, then you may have to track the Closures in execution, at the very least you will have to "rethrow" 3) Imagine each does also use a Closure with method return and our external Closure is executed within that Closure. Now you need to identify which Closure did the return 4) Exceptions are "slow" 5) Maybe we actually want continuations or virtual threads for this. bye Jochen
