Getting the const-correctness of Object sorted once and for all

Alex Rønne Petersen xtzgzorex at gmail.com
Sun May 13 23:28:32 PDT 2012


On 14-05-2012 08:26, Walter Bright wrote:
> On 5/13/2012 11:09 PM, Mehrdad wrote:
>> On Monday, 14 May 2012 at 04:10:30 UTC, Chris Cain wrote:
>>> Let me ask you something: Could you try to name 2 or 3 good things about
>>> const/immutable without looking it up? If not, you've really not
>>> given enough
>>> effort to learning about the benefits of it.
>>
>>
>> (1) Compiler helps you write correct multithreaded code
>> (2) You help compiler perform optimizations based on contracts
>> (3) I don't think there exists a #3 that's very different from #1 and #2
>
>
> #3 Improves self-documentation of code - it's more understandable and
> less susceptible to breakage during maintenance.
>
> #4 Improves encapsulation

I'm not sure I would agree on this one. const/immutable arguably leak 
implementation details more than they encapsulate them.

>
> #5 Makes function purity possible

-- 
- Alex


More information about the Digitalmars-d mailing list