What purpose to const besides functional programming?

Jason House jason.james.house at gmail.com
Wed Jul 23 08:30:48 PDT 2008


superdan Wrote:

> Jason House Wrote:
> 
> > Walter Bright Wrote:
> > > 5. Invariant data does not have to be synchronized to be multithread 
> > > accessible.
> > 
> > #5 is not true.  Invariant functions require synchronization because they can manipulate global state.  If #5 is restricted to direct data access without using properties or member functions, then I'd agree with it.  Of course, that qualification eliminates most of the benefit from #5. notice how walter says "data" and you say "function" and you'll pretty much have understood where the problem in your reasoning was.
> 
> of course #5 is true. looks like there was and still is a basic misunderstanding of data vs. function behavior with regard to immutability. 
> 
> don't confuse data with functions. invariant data -> can't modify it even with the sas. that means no synchronization on data necessary. invariant function -> applies to invariant object and may or may not require synchronization. but sure as shit invariant data does not need synchronization.


All of my posts on this topic are about invariant functions rather than invariant data.  Walter's response focused more on invariant data, and I'm intentionally trying to draw the distinction in what we're talking about.

I want to shift the discussion away from discussing purely invariant data and instead discuss the functions to access the data.  Proper object oriented programming requires using functions, so any proper analysis of a const system must include analyzing how functions are handled.



More information about the Digitalmars-d mailing list