them and an unqualified pointer if an unqualified pointer was passed to them. D In Version 2 of the , two keywords relating to const exist. The immutable keyword denotes data that cannot be modified through any reference. The const keyword denotes a non-mutable view of mutable data. Unlike C++ const, D const and immutable are "deep" or , and anything reachable through a const or immutable object is const or immutable respectively. Example of const vs. immutable in D int[] foo = new int[5]; // foo is mutable. const int[] bar = foo; // bar is a const view of mutable data. immutable int[] baz = foo; // Error: all views of immutable data must be immutable. immutable int[] nums = new immutable(int)[5]; // No mutable reference to nums may be created. const int[] constNums = nums; // Works. immutable is implicitly convertible to const. int[] mutableNums = nums; // Error: Cannot create a mutable view of immutable data. Example of transitive or deep const in D class Foo { Foo next; int num; } immutable Foo foo = new immutable(Foo); foo.next.num = 5; // Won't compile. foo.next is of type immutable(Foo). // foo.next.num is of type immutable(int). History const was introduced by Bjarne Stroustrup in C with Classes, the predecessor to C++, in 1981, and was originally called readonly. As to motivation, Stroustrup writes: "It served two functions: as a way of defining a symbolic constant that obeys scope and type rules (that is, without using a macro) and as a way of deeming an object in memory immutable." The first use, as a scoped and typed alternative to macros, was analogously fulfilled for function-like macros via the inline keyword. Constant pointers, and the * const notation, were suggested by Dennis Ritchie and so adopted. const was then adopted in C as part of standardization, and appears in C89 (and subsequent versions) along with the other type qualifier, volatile. A further qualifier, noalias, was suggested at the December 1987 meeting of the X3J11 committee, but was rejected; its goal was ultimately fulfilled by the restrict keyword in C99. Ritchie was not very supportive of these additions, arguing that they did not "carry their weight", but ultimately did not argue for their removal from the standard. D subsequently inherited const from C++, where it is known as a type constructor (not type qualifier) and added two further type constructors,