GAP-forum
On Wed, Mar 12, 2003 at 10:31:56AM -0500, Vahid Dabbaghianabdoly wrote:
> Dear Gap-Froum,
>
> I have written a recursive program on GAP which contains two
> subroutines A and B such that A calls B, and B calls A.
> When I define A at the first, GAP does not know B.
> and when I define B, it does not know A. And I receive
> "Syntax error: warning: unbound global variable".
> Do you know How I can fix that?
Interactively, you can safely ignore it ... it is just a warning.
However to define two functions f and g that call each other in
such a way that avoids the warning use DeclareGlobalFunction and
InstallGlobalFunction to define each function like this:
DeclareGlobalFunction( "f" );
DeclareGlobalFunction( "g" );
# that defines f and g to be the names of two functions
# without defining what they do
InstallGlobalFunction( f,
function(...)
# code here can refer to g
end );
InstallGlobalFunction( g,
function(...)
# code here can refer to f
end );
Regards,
Greg Gamble
Miles-Receive-Header: reply