Optimizing Immutable and Purity

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Dec 23 07:41:53 PST 2008


Bill Baxter wrote:
> On Tue, Dec 23, 2008 at 11:30 AM, Jerry Quinn <jlquinn at optonline.net> wrote:
>> Walter Bright Wrote:
>>
>>> I've been working on improving the optimizer to take advantage of
>>> immutability and purity.
>>>
>>> http://www.reddit.com/r/reddit.com/comments/7l5x4/optimizing_immutable_and_purity/
>>>
>>> http://dobbscodetalk.com/index.php?option=com_myblog&show=Optimizing-Immutable-and-Purity.html&Itemid=29
>> This was an interesting read.  It would be nice to see a discussion of how const is going to fit in in terms of optimization potential, since you can always cast it away.
> 
> It's basically useless for optimizations I think.
> Even if the view of the data you have is const, someone else might
> have a non-const view of the same data.
> So for instance, if you call any function, your "const" data could
> have been changed via non-const global pointers to the same data.
> 
> --bb

Const is still useful because inside a function you know for sure that 
another thread can't modify the data.

Andrei



More information about the Digitalmars-d mailing list