What would Squeak be like without non-local returns

Igor Stasenko siguctua at gmail.com
Wed Nov 7 06:07:24 UTC 2007


On 07/11/2007, Andreas Raab <andreas.raab at gmx.de> wrote:
> Rob Withers wrote:
> > Well, now I can't find that statement, but I was sure I had read it on
> > erights or Mark's thesis.  I searched and found nothing.  It may have
> > been a statement regarding eventual-sending specifically with non-local
> > return.  It IS strange thinking about the correct behavior of an
> > expression:
> >
> > object eventual ifTrue: [^3].
> > ^4
> >
> > What should be the result?
>
> Without any question, 4. Since ifTrue:[] is sent eventual it will return
> immediately (answering a promise), and the method will continue and
> return 4. There is absolutely no question about it.
>
> When the eventual ifTrue: is executed it will barf because it will try
> to return from a method with no home but that's the way out-of-scope
> blocks go. It's just as well-defined as a non-local return from an
> out-of-scope block today, e.g.,
>
> Foo>>createBlock
>    ^[^self]
>
> Foo>>callBlock
>    self createBlock value.
>
> This will simply signal BlockCannotReturn and the eventual ifTrue:[]
> will - and should - do the same.
>

Let suppose that Mr.Satan will rewrite an example above as following:

object eventual ifTrue: [100 atRandom seconds asDelay wait.  ^3].
100 atRandom seconds asDelay wait.
^4

When, in real case, a random delay could be replaced by any code which
needs a time to evaluate.
What is the answer then? :)

> Cheers,
>    - Andreas
>
>


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list