9.18 The Info Mechanism

Sometimes it is useful to get information about the progress of a calculation. Many GAP functions contain statements to display such information under certain conditions.

In GAP 3, these statements were calls to functions such as InfoGroup1 or InfoGroup2, and if the user assigned Print to these variables then this had the effect to switch on the printing of information. InfoGroup2 was used for more detailed information than InfoGroup1. One could switch off the printing again by assigning Ignore to the variables, and Ignore was also the default value.

GAP 4 uses one function Info for the same purpose, which is a function that takes as first argument an info class such as InfoGroup, as second argument an info level, and the print statements as remaining arguments. The level of an info class class is set to level by calling SetInfoLevel( class, level ). An Info statement is printed only if its second argument is smaller than or equal to the current info level. For example,

gap> test:= function( obj )
> Info( InfoGroup, 2, "This is useful, isn't it?" );
> return obj;
> end;;
gap> test( 1 );
1
gap> SetInfoLevel( InfoGroup, 2 );
gap> test( 1 );
#I  This is useful, isn't it?
1

As in GAP 3, if an info statement is ignored then its arguments are not evaluated.

[Top] [Previous] [Up] [Next] [Index]

GAP 4 manual
February 2000