[e-lang] How to deal with eventual sending with non-local returns
Kevin Reid
kpreid at mac.com
Wed Nov 7 09:22:30 EST 2007
On Nov 6, 2007, at 23:17, Rob Withers wrote:
> What does E do with this kind of expression:
>
> escape __break :any {
> def promise := bob <- foo(carol);
> when (promise p) -> done() {
> __break.run(p)
> }
> }
>
> ?
"promise p" isn't a valid expression, and the when/done are
unbalanced; I'll assume you meant something like
when (promise) -> done(p) {
or
when (def p := promise) -> {
(which are equivalent, and the latter is the current recommended
syntax).
Remember that 'when' is not a Kernel-E construct; it's just a
standard object (Ref) being invoked with an ordinary function holding
the body.
The applicable rule in this case is simple: ejectors have dynamic
extent. Calling an ejector after its corresponding escape block has
been exited causes the ejector to throw a complaint instead.
Since Ref.whenResolved doesn't invoke the when block's body function
until some future turn, when this code is first executed it simply
falls off the end of the escape block, returning what 'when' returns
(which is a promise for the result of the body).
When the when body is run, __break will throw reporting that it is
invalid, and (as with any other throw from a similar point) that
exception will be in the tracelog, and in the broken reference which
the promise for the result of the when expression resolves to.
See http://www.erights.org/elang/kernel/EscapeExpr.html for more
information and other unusual cases.
> ----- Original Message -----
> From: "Rob Withers" <reefedjib at yahoo.com>
Please place your quotations above your responses, in the standard
format for such (attribution line, "> " quoting), and trim them to
only relevant text.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list