explicit return from a block
Klaus D. Witzel
klaus.witzel at cobss.com
Tue Jun 27 08:14:30 UTC 2006
Hi Viktor,
on Tue, 27 Jun 2006 09:23:15 +0200, you wrote:
> Is there any way to explicitly return from a BlockContext/BlockClosure
> (like ^some-expression in methods) but without returning from the parent
> context (method)?
You can move the block into another method and do the [^ return] there.
This will keep your calling method (your parent) active.
> I'm beginning to figure out how to avoid the need for
> "break&continue" in loops,
Ah, the GOF break&continue world ;-)
> and i know that i can even avoid the need for
> explicit return converting the block in question in a method, but there
> are places where a long block is much more convenient...
Yes, I also prefer to have all blocks in the same method. But under rare
circumstances some block has to be moved "out of the way" and this perhaps
befits your example.
I have methods that just create a block, like
makeBlock
^ [^ do this and that]
useBlock
collection do: self makeBlock
HTH.
/Klaus
> thanks
> vsv
>
>
>
More information about the Squeak-dev
mailing list
|