When is a closure a real one? [was: Real closures]

Hans-Martin Mosner hmm at heeg.de
Sun Oct 8 19:54:30 UTC 2006

J J schrieb:
> Yes I know.  What I meant was: I think the presence of ^ means your
> block can't be a complete closure.  I.e. you can't return it from a
> method and invoke it later, since it might try to return to a place
> that no longer exists.  I think the way ^ works is wonderful, but if
> the compiler sees one in a block it can treat that block differently
> then if one wasn't present.
Actually, the presence of a ^ does not matter much. It just means that
the return statement within that block can be used only once(*). But the
block can be used any number of times before and after that.

(*) In the presence of continuations and stack saving/restoring
mechanisms such as seaside, it might even make sense to return from a
method context more than once - if the reincarnation of the context is
the same object. In seaside, it actually is so (the complete chain of
contexts is saved when a continuation is created, and is repopulated
with its saved values including caller linkage when it is re-evaluated).
A method return from a block is valid exactly if the home context of the
block is in the current context's call chain. Whether the method context
has been returned from in a previous life does not matter.


More information about the Squeak-dev mailing list