[GAP Forum] Unbound global variable error
Vipul Naik
vipul at math.uchicago.edu
Thu Aug 30 21:32:50 BST 2012
Hello,
It is probably the ordering of your function definitions within the
file. Try placing the definition of Foo2 above the definition of Foo1.
GAP reads the file linearly. This means that when it reads Foo1, it
doesn't know what Foo2 is because that point in the file hasn't been
reached yet.
If you don't want to change the order of the definitions, the problem
can be overcome by reading the file twice, as at the second read of
the file, GAP "knows" what Foo2 is.
Vipul
* Quoting Ha T. Lam who at 2012-08-30 16:17:18+0000 (Thu) wrote
> Sorry if I double-post this question. I emailed the forum unsubscribed and
> have been waited moderating for a week. I thought I would try my chance
> again as a member.
>
> Dear GAP forum,
> >
> > I'm getting the unbound global variable error when I put the following in
> > a file and Read it in:
> > -------------------------------------------
> > Foo1:=function()
> > local g;
> > g:=2;
> > Foo2(g);
> > end;
> >
> > Foo2:=function(a)
> > Print(a,"\n");
> > end;
> >
> > Foo1();
> > -------------------------------------------
> >
> > Syntax error: warning: unbound global variable in temp.gi line 6
> > Foo2(g);
> > ^
> >
> > I'm running GAP 4.5.5. Actually I have a bigger program that gives me
> > various unbound global variable errors, but I've stripped it down to this,
> > and still have the error. Any idea why?
> >
> > Ha T. Lam
> >
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
More information about the Forum
mailing list