so what exactly is const supposed to mean?

Lars Ivar Igesund larsivar at igesund.net
Tue Jul 4 06:02:25 PDT 2006


David Medlock wrote:

> kris wrote:
>> 
>> Yes, it does sounds very familiar -- to take full advantage of specific
>> hardware you may need to step away from the 'norm'. Whatever that 'norm'
>> may be. No surprise then, that it pays to keep an open mind?
>> 
>> You won't hear any argument from me regarding the typical multithreading
>> "paradigm" ... and there are most certainly more effective methods in
>> one manner or another ... there have been for 30 years ... *shrug*
>> 
>> If you intend to go on a crusade, to change the face of multithreading
>> as we currently know and "love" it, I'll sign right up :D
>> 
>> But, again, the state of immutability is *not* married to multithreading
>> -- it just happens to be particularly useful there too :p
>> 
>> 
>> 
> Crusade? LoL.
> I can barely work on my own projects with my daughters(1 and 3 yrs).

What you mean? They can't code yet? ;)

> 
> My point was simply that const isn't the 'pot of gold' its made out to
> be(at least in the form espoused thus far).
> 
> 1. Tiny multithreaded advantages.
> 2. Limited optimization benefits.
> 3. Some memory optimizations for structs(call by reference).
> 
> Changing the whole language for the above just does seem like good
> investment vs return.
> 
> Cheers
> -David

I believe you downplay those points too much, particularly the multithreaded
advantages. You did also forget the most important point, IMO:

If you as a library writer or application writer care about the integrity of
your data (very often you have to, as this might be necessary to guarantee
correct operation), then you need to make sure that users of the library,
or other threads don't modify the data in ways that breaks this integrity.
Since D actually aims to make it easier to create safer software, strong
immutability enforcement, however it is implemented (the logical const from
C++ do seem like a somewhat dead end), is a must.

-- 
Lars Ivar Igesund
blog at http://larsivi.net
DSource & #D: larsivi



More information about the Digitalmars-d-learn mailing list