Warning, `...` is implicitly declared local to procedure `...` - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : System : Error Message Guide : isimplicitlydeclaredlocal

Warning, `...` is implicitly declared local to procedure `...`

 

Description

Examples

Description

Maple displays this warning when you do not declare a variable as local or global, and it is assumed to be local. Unless otherwise declared, each variable to which an assignment is made, or that appears as the controlling variable in a loop, is assumed to be local. All other undeclared variables are assumed to be global. No warnings are displayed for variables assumed to be global.

 

For details, see the procedure help page.

Examples

Create a procedure that increments x. For example, x can be a global counter that increments every time f is called.

 

x0;

x0

(2.1)

fprocax;x:=x+aend proc;

Warning, `x` is implicitly declared local to procedure `f`

fprocalocalx;x;xx+aend proc

(2.2)

Call f.

f3;

x+3

(2.3)

Note that x did not change.

x;

0

(2.4)

Solution

In some cases the warning can be ignored. However, it is better to declare all variables local or global explicitly. 

And in this example, to use f to modify the global variable x, x must be declared global.  

0

(2.5)

 

restart

x0;

x0

(2.6)

fprocaglobalx;xx+aend proc;

fprocaglobalx;xx+aend proc

(2.7)

Call f.

f3;

3

(2.8)

Note that x changes.

x;

3

(2.9)

See Also

for...while...do

procedure