[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
loopExitContinue/loopExitValueContinue
Ian just kindly explained loopExit to me so it seems I didn't phrase my
question clearly enough :-)
By loopExit[Value]Continue I mean loopExitContinue / loopExitValueContinue.
They're not explained in the manual (there's a comment in the
slot, but I couldn't correlate that with the code) and are not sent anywhere
so there's no example of how to use them.
How must a block look like that will respond correctly to this message?
What does any argument to `exit:' have to look like? For example, making
sense of the loopExit method is difficult without knowing that the block
that you send it to must have an `:exit' slot that takes the `escape'
block.
[Hmm, I just realize X-Copy/Paste doesn't work with the Self window :-{ ]
The comment says:
`Same as loopExit,
plus a second arg block that causes the loop body to restart'
Looking at the code a little harder, I can now make sense of that line.
([[| :exit |
value: [^ nil] With: [exit value].
] exit
] loop)
The message that will ultimately be sent to the receiving block is
the third line and a template for a receiver might look like this:
[| :exit. :continue. |
mandatoryCode.
shouldExit if: exit.
shouldShortCircuit: continue value. "Is the `value' necessary here?"
facultativeCode.
]
So this provides sth like C's `continue' keyword.
I think I understand how this works now, but I'm not 100% sure.
Rainer