On Sunday 28 November 2010 14:02:02 Walter Bright wrote:
> Jonathan M Davis wrote:
> > Walter is certainly against logical constness,
> 
> I don't know of any language that provides logical constness as a feature.
> I know of no way to make it a statically verifiable attribute. Doing it
> with runtime checks is arbitrarily complex (imagine having to verify with
> a runtime check that one didn't change a 1Gb data structure).
> 
> D has a focus on providing features that promote verifiability of programs.
> As programs inevitably get more complex, I believe this is crucial (as
> opposed to the older technique of relying on convention).

The more I look at your comments on the matter, the more I see that logical 
constness does not really give you any guarantees in the general case, because 
it's technically possible to cast it away and ignore it or just make all of 
your 
member variables mutable and ignore it. But (if nothing else, due to 
programmers 
not abusing it that badly) programmers don't usually view it that way. From the 
programmers point of view, it does provide guarantees, and in practice, I 
believe that it generally holds. But it is true that when you look at it, it's 
convention that's holding it together (albeit one which is generally followed). 
So, I do think that D has taken the correct route (though logical constness 
_can_ be really nice at times), but I'm sure that most programmers aren't going 
to see it that way (certainly not without a fari bit of convincing), especially 
when so many of them are used to going without it entirely.

I'm glad to finally understand why you're against logical constness though. I'd 
never quite understood it before. It's definitely food for thought.

- Jonathan M Davis

Reply via email to