Burton Radons wrote:
I don't get it either. Any possible application for const in the form
of code correctness went out the window once the invariant virus
forced all strings to be invariant whether they were or not; so I
still need to use dup to guarantee that data won't change underneath
me, but then I need to cast it!

My experience is that when dup is used to guarantee that the data won't change underneath the problem is being addressed at the wrong end. The mutator of the data dups it, not the user.

It doesn't affect pure at all,
because pure can be passed invariants which are just casted - the
compiler needs to use rules which are a hell of a lot more binding
than anything we can provide it to make these determinations. Now
that const is not a storage class, it's actually not possible to
declare function variables which should be stored in read-only memory
(unless if it's encoded somewhere in the thirty or so combinations
you can use), which also damages pure. It's a lot more confusing to
deal with const data altogether than it used to be.

When I switched from D 1.0 to 2.0 I tried several times to port some
large pieces of code over and ultimately gave up, just as everyone
has given up trying to do it in C++. It's a hard task moving code
through that kind of change.

I've learned to handle it but I would really like to not be fighting
the compiler all the time. Is that what I'm supposed to be doing
here, really?

Can you be more specific about what was stimying you, as perhaps we can think of a solution.

Reply via email to