const?? When and why? This is ugly!

Jason House jason.james.house at gmail.com
Mon Mar 2 07:11:18 PST 2009


grauzone Wrote:

> dsimcha wrote:
> > == Quote from hasen (hasan.aljudy at gmail.com)'s article
> > Uhh, that's what aliases are for.  The string alias is defined automatically in
> > object, and string is an alias for immutable(char)[].
> 
> That Phobos introduces this alias is not really an argument that speaks 
> in favor of the syntax.
> 
> Also, I don't quite understand yet what constness is good for. While it 
> seems to be a good idea, it seems to be more an annoyance in practice. 
> It doesn't seem to pay off. What is this additional complexity for? And 
> really, what was wrong with not having constness? All I hear is 
> something about threading, but I didn't see anything convincing yet. No 
> real examples, not even a full concept. Only some loose arguments. Come 
> on, the newest compiler releases can do const, now convince me already 
> that it's a good feature!

Given the tone of your messages, I assume convincing you is impossible. The biggest help I can offer is to tell you that "the D you loved" still exists as D 1.0... Walter still maintains the compiler for it and Tango, Descent, GDC, LDC, and many other things all support D1.
 
> Regarding pure functions: isn't CTFE already enough?

The big driver of D2 is provably safe multithreading without locks. Pure functions are the embodiment of that, and immutable data is required for that. Const is used to handle either mutable or immutable data. 

Does that help?



More information about the Digitalmars-d mailing list