up previous next

5.1.10 ComputationStack

If the ComputationStack option is on, a special variable named ComputationStack contains a list tracing errors that occur during the execution of CoCoA commands. This option is useful for debugging programs.

example

    
Define Test(X)
  If X>=0 Then PrintLn(1/X) EndIf;
EndDefine;

Set ComputationStack;
Test(0);


-------------------------------
ERROR: Division by zero
CONTEXT: 1 / X
-------------------------------
S := ComputationStack;  -- to save typing later
S[1];  -- the command that produced the error
PrintLn(1 / X)
-------------------------------
S[2];  -- S[1] was part of an If-statement
IF X >= 0 THEN PrintLn(1 / X) END
-------------------------------
S[3];  -- the command issued by the user 
IF X >= 0 THEN PrintLn(1 / X) END; 
-------------------------------