logo       

Re: How to know where a BlockClosure finish: msg#00235

lang.smalltalk.squeak.beginners

Subject: Re: How to know where a BlockClosure finish


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

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Beginners mailing list
Beginners@xxxxxxxxxxxxxxxxxxxxxxxxxx
http://lists.squeakfoundation.org/mailman/listinfo/beginners
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise