[Newbies] How to know where a BlockClosure finish
Marcus Denker
denker at iam.unibe.ch
Fri Aug 25 16:23:16 UTC 2006
On 25.08.2006, at 17:14, Mathieu wrote:
> Hi,
>
> I want to execute several block:
>
> block1 value
> block2 value
> block3 value
>
> but if one block return from a retrun statement I want to quit.
>
> [^3] <- want to quit here
> [3 + 4]
>
> So is there a way to know when a block evaluation finish by a return?
>
There is #hasMethodReturn in BlockContext:
[^3] hasMethodReturn --> true
[3] hasMethodReturn --> false.
But this does a static analysis of the code... even if the ^is not
executed
(e.g.)
[nil ifNotNil: [^3]] hasMethodReturn --> true
so... it would be harder to analyze that dynamically... e.g. (without
me thinking
to much) you could add code (e.g. using ByteSurgeon)
in front of the return inside a block to set a flag... but I have to
admit that this
woud be quite strange stuff...
> I need this to interprete a file containing smalltalk and I want to
> control the execution beceause I need to add some condition befor
> evaluate a block.
Why do you need that? I am sure we can find a simple solution if we
understand
the problem better.
Marcus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 3938 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/beginners/attachments/20060825/c46ef589/smime.bin
More information about the Beginners
mailing list