Extended Type Design.

Don Clugston dac at nospam.com.au
Fri Mar 16 12:42:30 PDT 2007


Frits van Bommel wrote:
> Andrei Alexandrescu (See Website For Email) wrote:
>> Don Clugston wrote:
>>> My problem is, I don't see any connection between "don't touch" and 
>>> "constant" except that C++ got them confused. In every other other 
>>> context outside of C++,  "constant" means "it will not change".
>>>
>>> Mathematically, you can "hold something constant" (even though it is 
>>> actually a variable), but as long as it is being held constant, it 
>>> can't change.
>>>
>>> Suppose in a function, you have 'const' access to a global variable.
>>> Another thread with write-access to that variable can change it, 
>>> while the function is executing.
>>>
>>> It makes sense for a function to have read-only access to a variable, 
>>> and need to obtain a mutex when it wants to obtain the current value.
>>> But that's not a constant in any reasonable sense of the word.
>>
>> The difference between math and computer memory is that all too often 
>> in the latter case you want to express modular separation very often. 
>> Modular separation (in this context) means that the right to modify a 
>> certain object is owned by some part of program, and other parts may 
>> be offered only a view of that memory. This is such an important 
>> concept, even C adopted it. All of C's library functions that take 
>> pointers are anontated in their signature to specify whether or not 
>> they modify their input or not.
>>
>> You want to enforce modular mutability cheaply. If D's immutability 
>> features fail to achieve that, we've done nothing.
> 
> I don't think he's arguing against immutable views, just against calling 
> it 'const' ;).

Exactly. Thank you. I'm purely concerned about the name.



More information about the Digitalmars-d mailing list