status of 'lazy' ?

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sat Feb 17 10:05:33 PST 2007


Michiel wrote:
> Speaking of const (and sorry if I'm off topic here), I'm missing
> something in D. Const functions like in C++. As in: functions that don't
> change the member vars of the class.
> 
> Is there a reason this got left out? I always thought it was useful.
> Could just be my C++ bias, though. ;)
> 

Const methods are truly useful only within a comprehensive notion of 
constness. The current plans are to make "const" stand for "really 
really const" (e.g. will not change through the lifetime of the symbol), 
and "in" to stand for "won't modify through this particular symbol". In 
essence, regular mutable data will be addressable through an "in" 
reference, but not through a "const" reference. Truly "const" data can 
be addressed via an "in" reference. Example:

void say(in char[] data)
{
   writefln(data);
}

const char[] rom = "I am super-immutable";
char[] mutable = rom.dup;

say(rom); // ok, const -> in works
say(mutable); // ok, mutable -> in works


Andrei



More information about the Digitalmars-d mailing list