-
Notifications
You must be signed in to change notification settings - Fork 32
/
fanmailAsk.rho
40 lines (35 loc) · 939 Bytes
/
fanmailAsk.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
new alice, bob, eve, stdout(`rho:io:stdout`) in {
// Alice get a lot of fan mail, so she
// creates a new write only bundle and publishes it.
new aliceFanMail in {
// Alice returns fanmail channel to any fan that asks
for (return <= alice) {
return!(bundle+ {*aliceFanMail})
}
|
// Alice also reads fan mail
for (mail <- aliceFanMail) {
stdout!("Alice received a fanmail")
}
}
|
// When Bob wants to send fanmail he asks for the channel
// and then sends
new return in {
alice!(*return) |
for (aliceFanMail <- return) {
aliceFanMail!("Dear Alice, you're #TheBest")
}
}
|
// Eve tries to intercept a message, but cannot
// because Alice's channel is write-only
new return in {
alice!(*return) |
for (aliceFanMail <- return) {
for (@stolenMail <= aliceFanMail) {
stdout!(["Eve stole a message: ", stolenMail])
}
}
}
}