Stack

Every script has a stack. A stack is a memory area that has a fixed size, data can be allocated and deallocated only at the top, but allocation is fast. Each local variable of the script is allocated on the stack. Variables declared on the stack are always in some block. A block defines some scope, when the instruction pointer gets out of the scope, all variables defined in that scope are destroyed (this behaviour is the same as in C++).

Below an example of stack variable declaration. It is very similar to C++ stack variables. The vector class may be found in Total Overscript demo.


Vec2f v(10, 10);   //parametrized constructor  
Vec2f y;           //default constructor
{                  //block - defines a scope
  Vec2f v(20, 20);
  y = v;           //now v = [20,20]
}                  //desctructor for v (two lines above) called
y = v;             //now v = [10,10]