Bill Allombert on Wed, 22 Feb 2012 20:50:38 +0100


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: breakpoint


On Mon, Feb 13, 2012 at 12:20:16AM +0100, Bill Allombert wrote:
> Dear PARI developers,
> 
> We have discussed the implementation of a breakpoint in GP.
> In its simplest form the implementation is as follow:
> void pari_breakpoint(void) { cb_pari_sigint(); }
> and the relevant file in src/functions/programming.
> 
> You insert a call to breakpoint() somewhere in your GP program, and when reached,
> this simulate a SIGINT (control-C) which cause GP to enter the breakloop and
> allow you to inspect the state of the program, and allow you to quit the breakloop
> and continue to run the program.
> 
> There are several questions:
> 1) Should we enter the breakloop when default(breakloop) is 0 ?
> 2) Should we make it a GP specific feature (on the ground that other PARI shells
> do not implement the breakloop) ?

We decided for 1) yes/ 2) yes, because we assumed that a user using breakpoint
want to enter thr breakloop, and 1) yes/ 2) no was problematic to implement.

I just commited 8358114b101 which adds the breakpoint function.
Example:

? f(N,x)=my(z=x^2+1);breakpoint();gcd(N,z^2+1-z);
? f(221,3)
  ***   at top-level: f(221,3)
  ***                 ^--------
  ***   in function f: my(z=x^2+1);breakpoint();gcd(N,z
  ***                              ^--------------------
  ***   Break loop: type <Return> to continue; 'break' to go back to GP
break> z
10
break>
%2 = 13

Cheers,
Bill.