Bill Allombert on Wed, 08 Nov 2006 23:07:58 +0100


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

Re: non-destructive interrupt of GP program


On Wed, Nov 08, 2006 at 01:43:10PM -0800, Max A. wrote:
> For simplicity assume that I run in GP the following program
> 
> for(i=1,10^20,n=i)
> 
> and want to interrupt it at some point and learn the value of n.
> If I just press ^C, the value n will be lost:
> 
> ? for(i=1,10^20,n=i)
>  *** for: user interrupt after 1,888 ms.
> ? print(n)
> n
> 
> Is there a way to interrupt computations such that the value of
> valuables is preserved?

Maybe trap() is what you are looking for ?

? trap()
? for(i=1,10^20,n=i)
  *** for: user interrupt after 1,665 ms.
  ***   Break loop (type 'break' or Control-d to go back to GP)
[type <Return> in empty line to continue]
break> print(n)
811758

Cheers,
Bill