| final |
|
grammar |
| |
A qualifier for declarations that affects the permissions of the
variable being declared by taking away write permission.
A
final
variable cannot be re-assigned, and if the variable is a pointer, write
permission of the target object are also taken away.
An object made
final
is completely unchangeable.
When
final
is used as part of a declaration,
its usage description can be summarized as follows:
Declaration:
final name DeclaratorList
| |
| Example: |
This example indicates the effect of
final
on a
String.
import yoix.stdio.*;
import yoix.string.*;
final String str[5,8] = "hello";
fprintf(stdout, "Initial value of 'str' is '%s'.\n", str);
try {
str = "re-assign pointer";
}
catch(e) {
fprintf(stdout, "We could not point 'str' to something else.\n");
return(true);
}
try {
*str = 'j';
}
catch(e) {
fprintf(stdout,
"Also, we could not change that to which 'str' points.\n");
return(true);
}
fprintf(stdout, "Value of 'str' is still '%s'.\n", str);
The results of this example on standard output are:
Initial value of 'str' is 'hello'.
We could not point 'str' to something else.
Also, we could not change that to which 'str' points.
Value of 'str' is still 'hello'.
| | |
| See Also: |
const,
reference
|
|
Yoix is a registered trademark of AT&T Intellectual Property.
|