Port

An automaton has a number of ports, through which data input and output are performed. There is no limit on the number of ports. If K is the maximum port number used in the automaton, then K ports will be created. Each port has two channels -- input channel and output channel. Each channel is like a queue -- data comes in from one end, form a chain, and goes out from the other end.

Inside the automaton, to output a piece of data to port

this.put(x)
or to output a piece of data to port
this.put(x, n)

To remove the next available piece of data from port , and assign it to x

x = this.get()
or to remove the next available piece of data from port
x = this.get(n)

Two attribute functions input and output can be used to send a piece of data to a port of an automaton, or receive a piece of data. They are used outside the definition of the automaton, i.e., in the surrounding scope of the automaton. For example,

A.input(x)   // input data at port 1
A.input(x, 2)   // input data at port 2
x = A.output()   // output data at port 1
x = A.output(2)   // output data at port 2

Example

u = automaton
        n = 0;
        while n == 0
             n = this.get();
             while n > 0
                  this.put(n);
                  --n;
                  stop;
             end
        end
    end

oz 2009-12-22