Bill Allombert on Thu, 07 Mar 2013 20:51:31 +0100

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

Re: PARI 2.6 syntax 1: iferr/iferrname

On Fri, Feb 15, 2013 at 10:22:08PM +0100, Bill Allombert wrote:
> On Fri, Feb 15, 2013 at 06:32:47PM +0100, Karim Belabas wrote:
> > * Bill Allombert [2013-02-14 22:42]:
> > [...]
> > 
> > I am not sure that two separate functions iferr / iferrname are useful.
> > We could have a single iferr() -- corresponding to current iferrname --
> > with the following syntax:
> A possibility is to discriminate on the number of arguments, like 'if' do.

While discussing with Karim, we decided to remove iferrname and allows:

iferr(seq1,E,seq2) \\ unchanged
iferr(seq1,E,seq2,pred) \\ only trap the error if pred is true
iferr(seq1) \\ = iferr(seq1,E,E)

An implementation of the 2 first synatx is available in the branch bill-iferr.

Unfortunately the third syntax is problematic, because iferr cannot differentiate
between iferr(seq1) iferr(seq1,E) and iferr(seq1,E,), and certainly
iferr(seq1,E,) should return gnil, not E in case of error.

Maybe we need to add explicit catch()/throw() functions instead.

We considered swapping seq2 and pred:
this is a bit more logical, but it is not in the spirit of GP to change meaning
of arguments based on the number of them.