Const template

Andrei Alexandrescu (See Website For Email) SeeWebsiteForEmail at erdani.org
Sun Jan 21 10:04:47 PST 2007


Lionello Lunesu wrote:
> "Andrei Alexandrescu (See Website for Email)" 
> <SeeWebsiteForEmail at erdani.org> wrote in message 
> news:eotmt2$2fru$3 at digitaldaemon.com...
>> The reflection mechanism would have to provide the information whether
>> or not a given member function changes the object.
> 
> How would that work? The difference between getters and setters is probably 
> easy to see, but what about member functions calling non-member functions? 
> Is the signature of that function (in,out,inout) enough to determine 
> mutability? Sounds like a C++-style const afterall.

Except that it's deduced. Think of it the other way: if const is an 
explicit Boolean flag that the compiler can check, it makes sense to 
have the compiler simply infer it.

> And how about the nested classes, or array members? I very much like the 
> idea though: generating getters with the same name as the members, but that 
> alone is not enough.
> 
> I get very confused thinking about this : S

Me too. I actually thought lazy is a storage class. It sure has the 
syntax of one in definition. It changes the use syntax (requires 
parens). And if I look at

http://www.digitalmars.com/d/lazy-evaluation.html

I see that lazy *is* a storage class.

My original suggestion was to simply convert expressions to delegates 
automatically. That setup has its own problems, but I think it's much 
easier to deal with them than it is with lazy.

A template can't detect lazy properly. It's unclear what it means to 
assign to a lazy parameter. Lazy is a storage class that changes the 
access syntax. I believe lazy is ill-designed. Walter should have stood 
the pressure and refuse to implement it without a clear definition.


Andrei



More information about the Digitalmars-d mailing list