[e-lang] [Fwd: Re: Proposal: E / Erlang integration]

Mark S. Miller markm@REDACTED
Fri Jun 9 09:48:52 CEST 2006

Mark S. Miller wrote:
> IIUC the behavior you're suggesting, the hardware failure case could be coded 
> in E as:
>               def [promise, resolver] := Ref.promise()
>               state := promise
>               when (lim <- msg(..)) -> {
>                   state := new_state
>                   resolver.resolve(pots)
>               } catch problem {
>                   resolver.smash(problem)
>               }

Oops, how embarrassing. The above code is clearly very broken: in the hardware 
failure case it leaves state bound to a broken promise. We need to add to the 
catch clause an assignment setting 'state' to whatever state we should be in 
following such a hardware problem. With this addition, the code can only be 
simplified to

               state := when (lim <- msg(..)) -> {
                   state := new_state
               } catch problem {
                   state := other_new_state
                   throw(problem) # breaks the promise for when's result

which is only a tad less verbose.

Text by me above is hereby placed in the public domain


More information about the erlang-questions mailing list