Logical const
Steven Schveighoffer
schveiguy at yahoo.com
Mon Nov 29 12:12:30 PST 2010
On Mon, 29 Nov 2010 14:52:54 -0500, Walter Bright
<newshound2 at digitalmars.com> wrote:
> Steven Schveighoffer wrote:
>> But in any case, const (even the non-logical variety) does not
>> guarantee purity. Only pure functions do that (always return the same
>> value for the same input)
>
> Right, but C++ doesn't have purity either. I was trying to make the
> point that C++ does not have a "logical const" language feature. It's
> only a convention.
Yeah, but saying because a const function in C++ might return a different
value because of logical const is, well, completely wrong :) Nobody is
expecting const to guarantee purity. Even a D const function cannot make
any assumptions about data that is const, because another alias could
change it.
Having a logical const feature in D would not be a convention, it would be
enforced, as much as const is enforced. I don't understand why issues
with C++ const or C++'s mutable feature makes any correlations on how a D
logical const system would fare. C++ const is not D const, not even close.
-Steve
More information about the Digitalmars-d
mailing list