protect
Protects a variable.
Syntax
-
protect(X)
-
X
is a variable
-
-
protect(s)
-
s
is a string containing the name of a variable
-
Description
If X
is a variable (or a string containing the name of a variable), then protect(X)
protects the variable. If successful, the function returns success
.
When a variable is protected, its value cannot be changed and it cannot be deleted.
Examples
a ≔ 5
5
a ≔ 6
6
protect(a)
success
a ≔ 7
failure
Cannot modify or delete protected variable "a".
Call stack: assign
delete(a)
failure
Cannot modify or delete protected variable "a".
Call stack: delete
unprotect(a)
success
a ≔ 8
8
delete(a)
success