> < ^ Date: Thu, 10 Feb 2000 18:21:17 +0100 (CET)
> < ^ From: Thomas Breuer <Thomas.Breuer@Math.RWTH-Aachen.DE >
< ^ Subject: Re: Ignoring errors.

Dear GAP Forum,

Nathan Dunfield asked

Is is possible to call a GAP function and simply ignore any errors it
generates and continue on regardless? Bill Thurston and I are going
through at large collection (10,000) of finitely presented groups and
applying a function to each of them which searches for finite index
subgroups with infinite abelianizations. So the code looks like:

for G in LargeCollectionOfGroups do

Now SearchForSubgroups sometimes fails because, say, a Todd-Coxeter
coset enumeration uses more than 256,000 cosets, or there's integer
overflow, or whatever. These failures are very rare, and since we
have a number of different variants of SearchForSubgroups, when
SearchForSubgroups fails, we just want to continue testing other
examples, and hope that one of the other methods works better next
time. But if one is running the code overnight, when there's a
failure in SearchForSubgroups early on, you end up sitting in the
break loop until morning.

In a language with exceptions, the code I want would look like:

for G in  LargeCollectionOfGroups do
  except:         # or, in C++, catch

Is this possible?

When GAP is started with the `-T' command line option,
break loops are disabled,
and errors simply cause GAP to return to the main loop.

Thus the task can be solved as follows.
For each group `G' to be inspected, one writes a line of the form
`SearchForSubgroups(G);' to an input file,
and then processes this file by a GAP that is started with the `-T' option.
As soon as an error occurs (for example one signalled by the coset
enumeration), GAP will proceed with the next input line.

I admit that this solution is not very elegant.
It may be that future versions of GAP will admit easier approaches.

Kind regards,

Miles-Receive-Header: reply

> < [top]