DMD 2.000 alpha release

Walter Bright newshound1 at digitalmars.com
Wed Jun 20 15:36:45 PDT 2007


Jascha Wetzel wrote:
> considering the 3 declarations
> 1) const(char)* p;
> 2) const(char*) p;
> 3) const char*  p;
> 
> i identify 3 entities in play here: the character *p, the address of 
> it's memory cell p and the location where that address is stored &p. the 
> language let's us change p and *p, &p is always invariant.
> in 3) p and *p are const,
> in 2) p is mutable and *p is const
> and 1) is the same!?
> 
> what is const in 2) that is mutable in 1) ?

In this case, there is no difference between (1) and (2), because a 
const type for a declaration's value is ignored.

For (3), const is being used as a storage class, not a type modifier, 
and so p is not mutable.



More information about the Digitalmars-d-announce mailing list