Transitive const sucks (pure)

Bruce Adams tortoise_74 at yeah.who.co.uk
Wed Sep 12 11:59:27 PDT 2007


Janice Caron Wrote:

> > You obviously missed the discussion of the "pure" keyword, borrowed from Fortran-90 from the conference. This is a clear way of declaring that a function must not have any side-effects.
> 
> 
> Cool!
> 
> But then, I don't understand Walter's objections to "logical constness".
> 
> Seems pretty simple to me. If a function is logically const but not
> truly const, then don't declare it pure.
> 
> Conversely, if it's not declared pure, then it can have logical constness.
> 
> Isn't that problem solved?

Getting constness and purity mixed up is liable to open a whole new can of worms. I humbly suggest you don't go there.

I not sure whetherpure functions can modify class variables. The presentation states that they can't modify anything reachable through their arguments. If we interpret "this" as a argument then pure methods must also be const in the C++ sense.



More information about the Digitalmars-d mailing list