Error, attempting to assign to `...` which is protected. Try declaring `local ...`; see ?protect for details.
This error occurs when you assign a value to a protected name. Protection is used to prevent names from being modified by the user.
One way to solve this error is to use a name that is not protected. However, if you prefer to use the protected name, you can do one of the following to avoid this error.
use local to declare a local version of the name (see Example 1)
use unprotect to remove protection from the protected name (see Example 2)
Note: It is not recommended that you remove protection from Maple protected names. If you must use a Maple protected name, you should declare a local version of the name.
Example 1: Declaring a protected name as local
An error is generated when you assign a value to a Maple protected name.
Error, attempting to assign to `diff` which is protected. Try declaring `local diff`; see ?protect for details.
The error is generated because diff is the Maple protected name for the differentiation command. To use a Maple protected name in your worksheet, declare the name using local.
Warning, A new binding for the name `diff` has been created. The global instance of this name is still accessible using the :- prefix, :-`diff`. See ?protect for details.
To access the Maple diff command, call :-diff. The following command differentiates ln(x) with respect to x.
You can even declare a local version of a name you already declared. The global (that is, original) name is again accessed by adding :- before the name.
myname≔global version of myname
local myname≔local version of myname
Warning, A new binding for the name `myname` has been created. The global instance of this name is still accessible using the :- prefix, :-`myname`. See ?protect for details.
myname≔local version of myname
local version of myname
global version of myname
Example 2: Using unprotect on a protected name
You can protect a name with the protect command. After protecting a name, an error is generated if you try to change the value stored in the protected name.
Error, attempting to assign to `myProtectedName` which is protected. Try declaring `local myProtectedName`; see ?protect for details.
Use the unprotect command to remove protection from your name and change its value.
Although you can use the unprotect command on a Maple protected name, this is not recommended because it alters the value of results. For example, consider the correct value of arctan(1).
Changing the value of Pi affects this and any other result containing Pi.
Download Help Document
What kind of issue would you like to report? (Optional)