|
- Channels and processes etc. are first class values,
so they can be computed, passed as parameters, and passed down channels,
of course.
-
- A single input- or output-action is arguably not a value as such,
in particular an input-action, such as inch?x,
needs a continuation, c,
if anything useful is to be done with the value
input to the variable x.
I.e. (λ cont.inch?x -> cont x)
will do, and the λ-expression is a value.
-
- In the following artificial example,
- outputB is an action (in the sense above)
to output 'B' on a fixed
channel, here output, and then continues
with outContinuation.
- outputX uses a fixed channel, output again,
but is parameterised on the value, X.
- inputX is an input action,
with continuation inContinuation which uses the value that is input.
- The sender gives these actions to the receiver
which makes use of them.
- The HTML form below can be used to run the example.
let ch=chan in let
receiver =
ch?chnl -> chnl!'A' -> {get & use a channel}
ch?outAction -> {get an output action}
outAction ( {& do the output act }
ch?outX -> {get an output action}
outX 'C' ( {& do it }
ch?inAction -> {get input action}
inAction ( {& do it }
lambda z.output!z -> {& use val}
stop))),
sender =
let outputB = {an output action, both channel and msg fixed}
lambda outContinuation. output!'B' -> outContinuation,
outputX = {an output action, only channel fixed}
lambda X. lambda outContinuation.
output!X -> outContinuation,
inputX = {an input action, channel fixed}
lambda inContinuation. ch?X -> inContinuation X
in ch!output -> ch!outputB -> ch!outputX ->
ch!inputX -> ch!'D' -> stop
in sender || receiver
{\fB Pass Input and Output Actions along (untyped) Channel. \fP}
|
|
pfl...
| | |
choice |
|| | parallel |
-> | sequence |
? | input act |
! | output act |
chan | new channel |
|
|
|