[e-lang] multiway when-catch
Rob Withers
reefedjib at yahoo.com
Mon Oct 29 14:16:53 EDT 2007
Hello again!
I've revived my work on SqueakElib and I am trying to implement the multiway
when-catch. I have #whenResolved: and #whenBroken: defined and that is how
I specify a when-catch; when-catch is not part of the language I use. I
suppose my first question is: is when-catch defined in terms of
#whenResolved: and #whenBroken:? If so, what does it look like?
Here is what I see as an example of the multiway when-catch in Walnut:
# E syntax
def maxTempVow := vehicleSpecsRcvr <- getMaxEngineTemperature(carType)
def engineTempVow := carRcvr <- getEngineTemperature()
when (engineTempVow,maxTempVow) -> {
if (engineTempVow > maxTempVow) {println("Car overheating!")}
} catch e {println(`Lost car or vehicleSpecs: $e`)}
and here is the equivalent syntax I am trying to support (Dining
Philosophers example):
(self leftDispenser getFork % self rightDispenser getFork)
whenResolved: [:lFork :rFork |
self leftFork: lFork.
self rightFork: rFork.
self startEating];
whenBroken: [:lFork :rFork |
self error: 'error getting forks'].
where #getFork returns an eventualRef and the #% message concatenates
promises to create a promiseSet. Unfortunately, nothing holds onto the
promiseSet so it is getting GCed. I suspect that I need to pass the
promiseSet as an argument to #whenResolved: msgs sent to each promise, but I
am not sure how.
I seem to recall an example of how to impl this using #whenResolved:, but I
can't find it. I may have been thinking of the resolveAllVow example, in
Walnut, but that is specified in terms of when-catch-finally. Another
thing that may help me is the elang code that defines when-catch.
Cheers,
Rob
More information about the e-lang
mailing list