Karim Belabas on Thu, 30 Oct 2008 01:53:26 +0100

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

Re: GP and syntax errors

* Jeroen Demeyer [2008-09-18 12:12]:
> This is an issue which I already raised on the pari-users list, but I  
> repeat it here in a longer way...
> I don't like the fact that syntax errors cannot be trap()ped anymore  
> with GP's new parser.  I can certainly agree with the explanation in  
> COMPAT that syntax errors and runtime-errors are completely different.  
> But now GP basically ignores syntax errors (apart from printing an error  
> message).
> I have a few automatic GP scripts, i.e. scripts which run without user  
> interface (like shell scripts).  For those scripts, it is very annoying  
> that there is no easy way to check for syntax errors.
> I would like to have some way of detecting (not even handling) syntax  
> errors more easily.  I would be happy with any of the following:
> a) add syntax errors back into trap().  You could even make it such that  
> you have to explicitly specify trap(syntax, ...) and that "syntax" would  
> not be trapped by default.
> b) add a new command syntax_trap() which would behave like trap() for  
> syntax errors.
> c) have a default along the lines of quit_gp_on_error which would exit  
> gp with a non-zero exit status whenever an untrapped (syntax) error is  
> encountered.
> I don't know how easy it is to implement either a) or b), but c) should  
> certainly be easy.

Just committed c) to svn. You can now set default(recover, 0)
[ prevents error recovery on untrapped errors -> immediate exit ].

Is that suitable ?


Karim Belabas, IMB (UMR 5251)  Tel: (+33) (0)5 40 00 26 17
Universite Bordeaux 1          Fax: (+33) (0)5 40 00 69 50
351, cours de la Liberation    http://www.math.u-bordeaux.fr/~belabas/
F-33405 Talence (France)       http://pari.math.u-bordeaux.fr/  [PARI/GP]