"Steven Schveighoffer" wrote in message news:[email protected]...
There are two solutions, both are horrible.

That's what scares me lol

There is a possible 3rd solution. Don't use immutable/const, instead use information hiding. In other words, Your class is already technically "immutable", since name will never mutate beyond the first setting. This requires coder discipline, and has no help from the compiler.

Yup.

But many languages that *don't* have const/immutable do well with this pattern (think Java strings).

Java strings are pretty poor for performance though. :\
You shouldn't be forced to choose between O(1) performance (versus O(n)) and the correctness of your program.

I have periodically mulled the idea of making a library-based solution for logical const. I think it would work, but you would have to be extremely cautious, and you lose some compiler guarantees for it. The most difficult part to deal with is how to prevent concurrent access, when an immutable object is always implicitly sharable.

Yeah, 'shared' also suffers from similar limitations...

I have another idea which gets around the problem in a different way. I think it's essential to bringing arbitrary ranges in line with current array features. When I have some time to flesh it out, I'll propose it. I think we absolutely can't be finished with ranges until this is implemented.

Okay nice. I also think this is 100% relevant to the range issue, so I don't think we will see a true fix until this problem is solved.

Reply via email to