[e-lang] How to deal with eventual sending with non-local returns
Rob Withers
reefedjib at yahoo.com
Fri Nov 2 21:23:48 EDT 2007
I am trying to add eventual sending to Smalltalk. The Smalltalk language
allows for multiple returns from a context with non-local returns:
foo: bar
bar ifTrue: [^ 1].
self snafu.
^ 0
If bar is eventual (I don't have syntax to do eventual sending, I make the
reference eventual so all sends to it are eventually sent), we don't know at
the time of invocation whether the method will exit through the non-local
return or through the return at the end of the method.
How to best deal with this?
My thought is that the context needs to become eventual, be sent as a lambda
to the bar promise, and the context return a promise. The return will check
to see if there is a resolver on the context and #resolve: it with the
appropriate return value. The lambda needs to be all sequential code from
the point where a message is sent to the promise that includes a block as an
argument to the end of the context. So the lambda would be:
f := [:barVow |
barVow ifTrue: [^1].
self snafu.
^ 0]
and we would send:
bar whenResolved: f.
Would this work?
thanks!
Rob
More information about the e-lang
mailing list