Skip to content

Instantly share code, notes, and snippets.

@willemneal
Created May 27, 2016 19:36
Show Gist options
  • Save willemneal/76757be24096dbaea31b22703c356838 to your computer and use it in GitHub Desktop.
Save willemneal/76757be24096dbaea31b22703c356838 to your computer and use it in GitHub Desktop.
Actor A sends a message to Actor B but it is intercepted by D. This can be generalized to have decorators that can catch messages.
actor A
let _b: B
let _d: D
let e: Env
new create(env: Env)=>
_b = B(env)
_d = D(env)
e = env
be messageB()=>
e.out.print("Calling B")
let b = _b
let f: {()} val = recover lambda()(b)=> b.foo() end end
_d(consume f)
actor B
let env': Env
new create(env: Env)=>
env' = env
be foo()=>
env'.out.print("In B")
actor D
let e: Env
new create( env:Env)=>
e = env
be apply(f: {()} val)=>
e.out.print("In D")
f()
actor Main
new create(env: Env) =>
let a = A(env)
a.messageB()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment