Passing array as const slows down code?

Steven Schveighoffer schveiguy at yahoo.com
Fri Apr 27 10:08:59 PDT 2012


On Fri, 27 Apr 2012 12:37:41 -0400, Joseph Rushton Wakeling  
<joseph.wakeling at webdrake.net> wrote:

> I have to say I'm somewhat confused about whether the pure markings are  
> really accurate.  The reputation() modifies the reputationUser_ and  
> reputationObject_ internal arrays and hence the returned values of  
> reputationUser() and reputationObject().  It's true that for a given  
> input to reputation(), the outcome will always be the same, but there's  
> nevertheless mutability involved: if I pass one input to reputation(),  
> and then another, the reputationObject() and ...User() outputs will  
> change as a result.

weak purity, I think, is one of the most revolutionary ideas to come from  
D.  Essentially, we get compiler-checked pure functions that can be  
written imperatively instead of functionally.

If the function is weakly pure, then it cannot be optimized based on  
purity, so I don't think there is any way marking it pure *hurts*.

-Steve


More information about the Digitalmars-d-learn mailing list