Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

Testing latest pari + WASM + node.js... and it works?! Wow.

28493 views
License: GPL3
ubuntu2004
Function: dbg_up
Class: gp
Section: programming/control
C-Name: dbg_up
Prototype: vD1,L,
Help: dbg_up({n=1}): (break loop) go up n frames, which allows to inspect data
 of the parent function.
Doc: (In the break loop) go up n frames, which allows to inspect data of the
 parent function. To cancel a \tet{dbg_up} call, use \tet{dbg_down}.
 \bprog
 ? x = 0;
 ? g(x) = x-3;
 ? f(x) = 1 / g(x+1);
 ? for (x = 1, 5, f(x+1))
    ***   at top-level: for(x=1,5,f(x+1))
    ***                           ^-------
    ***   in function f: 1/g(x+1)
    ***                   ^-------
    *** _/_: impossible inverse in gdiv: 0.
    ***   Break loop: type 'break' to go back to GP prompt
  break> x
  2
  break> dbg_up()
    ***   at top-level: for(x=1,5,f(x+1))
    ***                           ^-------
  break> x
  1
  break> dbg_up()
    ***   at top-level: for(x=1,5,f(x+1))
    ***                           ^-------
  break> x
  1
  break> dbg_up()
    ***   at top-level: for(x=1,5,f(x+1))
    ***                 ^-----------------
  break> x
  0
  break> dbg_down()    \\ back up once
    ***   at top-level: for(x=1,5,f(x+1))
    ***                           ^-------
  break> x
  1
 @eprog\noindent The above example shows that the notion of GP frame is
 finer than the usual stack of function calls (as given for instance by the
 GDB \kbd{backtrace} command): GP frames are attached to variable scopes
 and there are frames attached to control flow instructions such as a
 \kbd{for} loop above.