Fully transitive const is not necessary
Steven Schveighoffer
schveiguy at yahoo.com
Wed Apr 2 07:33:46 PDT 2008
"Janice Caron" wrote
> Bugger! That last post got sent before I'd finished writing it.
>
>> c.some.deeply.nested.but.reachable.var++; // OK (compiled with D2)
>
> Overriding "opPostInc() const" doesn't prove anything. If you want to
> make a serious point, just call you function f or foo or something.
> Using operator overloads to disguise what's going on doesn't make
> /anything/ clearer.
You are missing the point. x is part of the class state, because it is
accessible through var. It is a mutable part of the const class state
because it resides in global (non-const) space. You have to think outside
the box.
>> The point is that logical const is still possible, even with transitive
>> const, because the global namespace is not const.
>
> It seems you and I disagree about the meaning of the phrase "logical
> const". The ability to manipulate global variables does not constitute
> logical constancy in my book.
The ability to use global mutable variables as part of the class state is
the point.
>> HOWEVER, the point that everyone is arguing is why does logical const
>> make
>> pure functions or functional programming impossible? Clearly, it is
>> ALREADY
>> POSSIBLE to have logical const
>
> We are suffering from a communications difficulty caused by you and I
> using the same phrase ("logical const") to mean entirely different
> things. Unless we can agree on a common terminology, we're not going
> to be able to get anywhere with this discussion.
The communications gap is not in that I do not understand what logical const
is. The communications gap is that you are not understanding that what I
have posted is semantically equivalent to logical const. What I am showing
is that transitive const is the same as logical const because you can use
the always mutable global state as part of the class state. What this
translates to is that logical const is sufficient for multi-programming as
long as the correct rules are chosen.
What I am asking is, because semantically logical const is possible, why is
actual logical const not allowed?
-Steve
More information about the Digitalmars-d
mailing list