Name:

getbacktrace returns the list of Sollya procedures currently run

Library name:

sollya_obj_t sollya_lib_getbacktrace();

Usage:

getbacktrace() : void -> list

Description:

Example 1:

   > procedure testA() {
       "Current backtrace:";
       getbacktrace();
     };
   > procedure testB(X) {
       "X = ", X;
       testA();
     };
   > procedure testC(X, Y) {
       "X = ", X, ", Y = ", Y;
       testB(Y);
     };
   > testC(17, 42);
   X = 17, Y = 42
   X = 42
   Current backtrace:
   [|{ .passed_args = [| |], .called_proc = proc()
   {
   "Current backtrace:";
   getbacktrace();
   return void;
   } }, { .passed_args = [|42|], .called_proc = proc(X)
   {
   "X = ", X;
   testA();
   return void;
   } }, { .passed_args = [|17, 42|], .called_proc = proc(X, Y)
   {
   "X = ", X, ", Y = ", Y;
   testB(Y);
   return void;
   } }|]

Example 2:

   > getbacktrace();
   [| |]

Example 3:

   > procedure printnumargs(X) {
       var L, t;
       "number of arguments: ", X;
       L = getbacktrace();
       "Backtrace:";
       for t in L do {
         "  " @ objectname(t.called_proc) @ ", ", t.passed_args;
       };
     };
   > procedure numargs(l = ...) {
       "l[17] = ", l[17];
       printnumargs(length(l));
     };
   > procedure test() {
       numargs @ [|25, 26, 27 ...|];
     };
   > test();
   l[17] = 42
   number of arguments: infty
   Backtrace:
     printnumargs, [|infty|]
     numargs, [|25, 26, 27...|]
     test, [| |]
See also: proc, procedure, objectname, bind, @
Go back to the list of commands