You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the closure, when invoked, will return from the method. It's already defined that such closures aren't allowed to call "return" if they've escaped from the method. Are there any other restrictions e.g. if you have a multiply nested closure such as:
m = (
[ [ ^nil] value ] value.
)
must it be at least 2 frames deep for the return to be valid?
The text was updated successfully, but these errors were encountered:
Hmmm, I am not sure I understand. Could you elaborate?
What does the it refer to, the block?
This here should print 42:
Hello = (
| field |
aMethod = (
[ field := [ ^ 42 ] ] value.
field value.
)
run = (
self aMethod println.
)
)
I think, there are no further restrictions, and, there's no "lexical" binding or similar going on.
The semantics of the return are dynamic, and for instance for recursive versions of m, you'd need to return from the correct m.
OK, that example (aMethod) pretty much answers my question. I wondered if the fact that the "outer" block had completed before the "inner" block did a closure return was against the spec, but it seems not :)
Ah ok, so, within the method, the blocks can freely flow between scopes, as normal objects, and they are still normal objects.
The only requirement is that the outer method, in my example aMethod, is on the stack. No further requirements where it is on the stack when the return is triggered.
So, any assumptions you may want to make, for instance, to optimize stack unrolling, would not necessarily hold in the most general case.
If I have a method along the lines of:
the closure, when invoked, will return from the method. It's already defined that such closures aren't allowed to call "return" if they've escaped from the method. Are there any other restrictions e.g. if you have a multiply nested closure such as:
must it be at least 2 frames deep for the return to be valid?
The text was updated successfully, but these errors were encountered: