Warning: ... is implicitly declared local to procedure ...

Maple provides this warning when you define a function using a variable which you do not declare as local or global, but which Maple assumes is local. Maple makes this assumption for any undeclared variable that is assigned a value in the procedure, or is the index variable in a for loop. Any other undeclared variable is assumed to be global, and no warning is given for it.

If you have no objection to the variable being local, you can ignore the warning. It is generally a good idea for index variables in for loops to be local, because you usually don't need or want to refer to these variables outside the loop. However, in some cases you do want the variable to be global. In particular, a common situation would be where you use a procedure to set the values of some global variables. Or you may want to have access to the values of some variables from another procedure which this one calls, without using a formal parameter. In these cases, you should use the global declaration to make the variables global.


The variable y is assigned a value in the following procedure, and therefore is taken to be local.

> foo:= proc(x) y:= x+1 end;

Warning, `y` is implicitly declared local to procedure `foo`

foo := proc (x) local y; y := x+1 end proc

Since it is local, the procedure has no effect on the global variable y :

> foo(3): y;


If the procedure is to be used to assign a value to y , that variable should be declared global.

> foo:= proc(x) global y; y:= x+1 end;

foo := proc (x) global y; y := x+1 end proc

> foo(3): y;


In the next example, in order for both procedures a and b to have access to variable y (without passing that name as a formal parameter) , it must be declared global in both procedures.

> a:= proc(x) global y; y:= 1; b(x); y end;

a := proc (x) global y; y := 1; b(x); y end proc

> b:= proc(x) global y; y:= y + x end;

b := proc (x) global y; y := y+x end proc

> a(3);


Index variable in a for loop:

> foo:= proc(x) for j from 1 to x do print(`Hello`,j) od end;

Warning, `j` is implicitly declared local to procedure `foo`

foo := proc (x) local j; for j to x do print(Hello,...

See also: procedure , for

Maple Advisor Database R. Israel, 2000