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

Walter Bright newshound2 at digitalmars.com
Sun May 13 23:26:07 PDT 2012


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

#5 Makes function purity possible


More information about the Digitalmars-d mailing list