sanjay@CS.UCLA.EDU (Sanjay Jain) (11/25/88)
Dear Mailing List :
I have just started programming in OCCAM, and had problems using arrays of
channels with variant protocols. I am submitting 2 programs with this posting.
In both if these, I define a variant protocol and then proceed to use it. The
only difference between the two programs is that the first program uses the
channel x, and the other uses x[1]. I would have expected both of these programs
to work, but only the first one does.
If it is relevant :I am using the transputer development system provided by INMOS.
I would be very grateful, if someone on the net could tell me what is wrong with
what I am doing, or if this is a bug in the OCCAM compiler.
thanx
sanjay
--------------------------------------------------------------------------------
Program One
--------------------------------------------------------------------------------
PROC ins.sort(CHAN OF ANY kbd, scrn)
#USE "\tdsiolib\userio.tsr"
PROTOCOL Messages
CASE
a; INT
b
:
CHAN OF Messages x :
INT l,tmp :
SEQ
PAR
SEQ
x ! a; 1
x ! b
SEQ
x ? CASE
a; tmp
SKIP
x ? CASE
b
SKIP
INT any:
SEQ
write.full.string(scrn, "hit any key to continue")
newline(scrn)
read.char(kbd,any)
:
--------------------------------------------------------------------------------
Program Two
--------------------------------------------------------------------------------
PROC ins.sort(CHAN OF ANY kbd, scrn)
#USE "\tdsiolib\userio.tsr"
PROTOCOL Messages
CASE
a; INT
b
:
[2]CHAN OF Messages x :
INT l,tmp :
SEQ
PAR
SEQ
x[1] ! a; 1
x[1] ! b
SEQ
x[1] ? CASE
a; tmp
SKIP
x[1] ? CASE
b
SKIP
INT any:
SEQ
write.full.string(scrn, "hit any key to continue")
newline(scrn)
read.char(kbd,any)
:
--------------------------------------------------------------------------------
Sanjay Jain
E Mail : sanjay@cs.ucla.edu US Mail: 11805 Idaho Ave #2
Phone : (213) 826 4950 Los Angeles CA 90025
--------------------------------------------------------------------------------