Chapter 3 has introduced token-passing continuations with the reserved keyword token. In this section, we will focus on the other type of continuations, the named tokens.
Warning: Tokens can ONLY be used as arguments to messages. SALSA 1.1.2 does not allow to use tokens as part of expressions (e.g., x+2) or to be used as return values (e.g., return token). |
//line 1 is equivalent to lines 2-3 1. hello() @ standardOutput<-print(token); |
token x = a<-m(); token y = b<-o(); token z = c<-p(); |
module examples; |
1. token y = a<-m1(); 2. 3. token z = y; 4. 5. y = b<-m2(y); 6. self<-m() @ c<-m3(token, z, y); |
//lines 1-2 are equivalent to lines 3-5 1. token x = a<-m1(); 2. x = b<-m2(x); |
1. token x = a<-m1(); 2. for (int i = 0; i < 10; i++) x = b<-m2(x, i); |
a<-m1() @ b<-m2(token, 0) @ b<-m2(token, 1) @ b<-m2(token, 2) @ b<-m2(token, 3) @ b<-m2(token, 4) @ b<-m2(token, 5) @ b<-m2(token, 6) @ b<-m2(token, 7) @ b<-m2(token, 8) @ token x = b<-m2(token, 9); |
1. token x = a<-m1(); 2. 3. for (int j = 0; j < 10; j++) { 4. b<-m2(x); 5. x = c<-m3(x); 6. d<-m4(x); 7. } |