immutable and inout, to handle related use cases. Other languages Other languages do not follow C/C++ in having constancy part of the type, though they often have superficially similar constructs and may use the const keyword. Typically this is only used for constants (constant objects). C# has a const keyword, but with radically different and simpler semantics: it means a compile-time constant, and is not part of the type. Nim has a const keyword similar to that of C#: it also declares a compile-time constant rather than forming part of the type. However, in Nim, a constant can be declared from any expression that can be evaluated at compile time. In C#, only C# built-in types can be declared as const; user-defined types, including classes, structs, and arrays, cannot be const. Java does not have const – it instead has final, which can be applied to local "variable" declarations and applies to the identifier, not the type. It has a different object-oriented use for object members, which is the origin of the name. The Java language specification regards const as a reserved keyword – i.e., one that cannot be used as variable identifier – but assigns no semantics to it: it is a reserved word (it cannot be used in identifiers) but not a keyword (it has no special meaning). It is thought that the reservation of the keyword occurred to allow for an extension of the Java language to include C++-style const methods and pointer to const type. An enhancement request ticket for implementing const correctness exists in the Java Community Process, but was closed in 2005 on the basis that it was impossible to implement in a backwards-compatible fashion. The contemporary Ada 83 independently had the notion of a constant object and a constant keyword, with input parameters and loop parameters being implicitly constant. Here the constant is a property of the object, not of the type. JavaScript has a const declaration that defines a block-scoped variable that cannot be reassigned nor redeclared. It defines a read-only reference to a variable that cannot be redefined, but in some situations the value of the variable itself may potentially change, such as if the variable refers to an object and a property of it is altered. See also Single assignment restrict Pointer aliasing Notes References External links "Const-Correctness" by Herb Sutter "Constant Optimization?" by Herb Sutter The C++ FAQ Lite: