What is the difference between...

Nathan Reed nathaniel.reed at gmail.com
Fri Sep 7 15:40:19 PDT 2007


Bruno Medeiros wrote:
> This 'head'/'tail' Robert 
> has been mentioned seems related. Seems the term 'head' is the same as 
> 'top-level value'.
> 

Yes.  The 'final' storage class makes the head const, which as you've 
pointed out can't be done with the 'const' type constructor.  So:

const(int)* x;        // mutable pointer to const int
const(int*) x;        // mutable pointer to const int
final const(int)* x;  // const pointer to const int
final const(int*) x;  // const pointer to const int

(This is described on the lecture slides from the conference, so I'm not 
sure if it is implemented quite this way yet.)

However, there is also still the 'const' storage class (as distinct from 
the type constructor)...it's not clear to me exactly how that differs.

Does anyone else think this is much too confusing?  I realize D const is 
a different animal from C++ const, but it seems to be badly in need of 
some simplification.

Thanks,
Nathan Reed



More information about the Digitalmars-d mailing list