Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Both sides next revision
alvis:stepscounting [2013/12/31 10:47]
marcin created
— (current)
Line 1: Line 1:
-====== Steps counting ====== 
  
-Let us focus on the **step** idea. It is necessary to distinguish between **code statements** and **steps**. Most of the Alvis statements e.g. **exec**, **exit**, etc. are **single-step statements**. On the other hand, **if**, **loop** and **select** are **multi-step statements**. We use recursion to count the number of steps for multi-step statements. For each of them, the first step enters the statement interior. Then, we count steps of statements put inside curly brackets.  
- 
-For a given statement //s//, let //stepno//(//s//) denote the number of the step related to //s//. For multi-step statements, //stepno//(//s//) denotes the number of the step connected with entering the statement interior. 
- 
-Let us consider the piece of code shown in Listing 1. The steps number are put inside comments. For example, the step 7 denotes entering the **if** statement, while the step 8 denotes the **out** statement.  
- 
-<code> 
-agent A { 
-  i :: Int = 0; 
-  loop {                            -- 1 
-    select {                        -- 2 
-      alt (i == 0) {  
-        in p;                       -- 3  
-        i = 1;                      -- 4 
-      }   
-      alt (i == 1) {  
-        in q;                       -- 5 
-        i = 0;                      -- 6 
-      } 
-    } 
-    if(i == 1) {                    -- 7 
-      out p;                        -- 8 
-    }          
-    else {  
-      null;                         -- 9 
-    }   
-  } 
-}   
-</code> 
- 
-**FIXME** 
- 
-**[[:alvis:manual|Go back]]**