Think Stitch
﻿

# The Reuses of Processes with Parameters

You can reuse processes by parametrized events and channels they use, instead of renaming. In the case of process expressions, process parameters can be used for it. In the case of state-transition diagrams, state variables can be used.

Let's see an example of state-transition diagrams. We define a queue process shown below. In contrast to the definition we saw in the article for the reuses by renaming, the process has four variables in, out, n, and q. The variable q is the list holding data. The variable in and out indicates channels for input and output respectively. The variable n indicates the maximum number of data the queue can hold. You can use the process in many cases by assigning actual channels to in and out/

These state variables except q are not changed on any transition. In order to emphasize it, the target expressions are used. This clearly shows us that only the variable q is changed.

We need specify concrete channels for the variables to use the process. In this case, channels which has the same name to the parameters are prepared. (It might be a bad choice :P)

(define D '((0) (1) (2)))

(define-channel in (x) D)
(define-channel out (x) D)


In order to explore the process QUE, the initial values of the variables are needed to be specified in the process property window. In this case, suppose the maximum number of data n is 3.

The computation tree is as follows:

You can see that the actual channels are stored in the variables on the environment window.

It is the matter of taste which way is to be used, renaming or parametrization.

# An Example of Reuses

Let's make two instances of the process QUE and concatenate them. We need a channel mid to interface them.

(define-channel mid (x) D)


Suppose the length of queues are 2 and 3. The reuses with parameters on the parallel composition seems to be easier than by renaming.

(define-process SYS
(hpar (list mid)
(QUE in mid 2 '())
(QUE mid out 3 '())))


The concatenated queues is supposed to be able to hold five elements maximum. We can check this by comparing SYS with (QUE in out 5 '()). The result is yes.

11 August, 2013