Trass3r wrote: > >In TDPL const/immutable are type qualifiers. Type qualifier is a > >synonym for type modifier, isn't it? And I know storage classes like > >static/ref. In C you have the type qualifiers const, volatile, and > >restrict and the storage classes auto, register, static, extern. Now > >const in D is a storage class? > > I also think const char* x in D2 is equal to const(char*) x while a > direct translation would be const(char)* x > So you might use the former version to keep compatibility with D1.
Haven't thought about that. Right. In D2 const T* is equal to const(T*). Let's check all the possible cases: void foo(const int *non_const_ptr_to_const, char *const const_ptr_to_non_const, const float *const const_ptr_to_const); In D2 you cannot express char *const. That's due to the transitivity of const. You can only do a const char* which is a constant pointer to constant. That's why I think foo should become in D2 void foo(const int*, char *, const(float*)); What do you think? I do not know much about D1. Is const transitive in D1? I think the page http://www.digitalmars.com/d/2.0/const3.html should not talk about storage class in regard to const and immutable. Jens