Programming Language Qualifiers Examination Spring, 2001
Question 1:

Coroutine A Coroutine B Coroutine C
![]()
![]()
if ( )
resume B resume C
//
address = 1000; //
address = 2000; resume A
//
address = 3000;
if ( )
resume C
// address = 4000;
Return address 1000 2000 3000
4000![]()


In the above example, each time when a resume ID is called, traditional imperative
Language will first memorizing the return address and then go to the address of the
Returned address of that coroutine.
Assumption: Dynamically determine the returned address in the run time for
Each coroutine.
Question 2:
For above example,
Compiler can staticly
determine an array of pointer, such as
Code *return[3];
And then the above codes
were compiled as follows:
return[0] = &A;
return[1] = &B;
return[2] = &C;
Code *cp, *temp;
// Resume B
temp = cp;
cp = return[1];
return[0] = temp;
goto cp;
// Resume C
temp = cp;
cp = return[2];
return[1] = temp;
goto cp;
// Resume A
temp = cp;
cp = return[0];
return[2] = temp;
goto cp;
// Resume C
temp = cp;
cp = return[2];
return[0] = temp;
goto cp;
Question
3
Intuitively we may need to
modify the “store” definition.
From
Store : Location à Denotable_Value
To
Store: Id à Value, where
Value = Nat + ( Command à Store à Store )