Warning: new definition for ...

This warning occurs when you use with to load a package, and the package includes a new definition for a name that previously had a different value (which might be from the standard library, from another package, or defined by the user). The new definition replaces the old definition (even though the names are protected). For example, the linalg package contains definitions for norm and trace , replacing standard library functions with those names.

These warnings can normally be ignored, except of course if you want to use the old definitions that have been replaced, or if you want to use a procedure whose definition includes a reference to them. Note that in Maple, names in a procedure body are evaluated when the procedure is invoked, not when it is defined, so the current definition is always used. Thus nothing that depends on the old procedure is likely to work any more.

In order to use the old definitions when the new package is loaded, you may be able to access them under another name. They should be assigned to other names before loading the new package. In the case of a function that refers to the old names, you can use subs to replace references to the old name by references to the new name. However, this can be complicated because in many cases there may be several levels of procedure calls before the actual call to the procedure in question.

An alternative, if you only need a few of the procedures in the package, is to avoid loading the whole package. Either load a few procedures that do not conflict with these names, or access the procedures in the long form using the name of the package.

Examples:

The norm function in the standard library calculates the norm of a polynomial.

> norm(1+x^2,2);

[Maple Math]

> with(linalg):

Warning, new definition for norm

Warning, new definition for trace

The standard library definition of norm is now replaced by the linear algebra definition.

> norm(1+x^2,2);

Error, (in norm) expecting a matrix or vector

We could have saved the standard library definition under a new name before loading the package. Note the use of eval , because we want to save the definition of norm rather than the name. The restart is needed because once the package is loaded, the original definition has been lost.

> restart;
polynorm:= eval(norm);

[Maple Math]

> with(linalg):

Warning, new definition for norm

Warning, new definition for trace

> polynorm(1+x^2,2);

[Maple Math]

If we want to use a procedure that calls norm (expecting the standard library version rather than the linear algebra one), we can change to the new name with subs . Again note the use of eval to obtain the definition.

> norm2:= p -> norm(p,2);

[Maple Math]

> newnorm2:= subs(norm=polynorm, eval(norm2));

[Maple Math]

The simpler alternative would be to only load selected procedures from the package, not including the ones that conflict with other names, and refer to those that do using the long form.

> restart;
with(linalg, matrix, vector):

> norm(1+x^2,2);

[Maple Math]

> linalg[norm](vector([1,2]));

[Maple Math]

See also: eval , subs , with , linalg

Maple Advisor Database R. Israel, 1997