Fully transitive const is not necessary
Michel Fortin
michel.fortin at michelf.com
Wed Apr 2 05:12:21 PDT 2008
On 2008-04-02 04:14:28 -0400, "Janice Caron" <caron800 at googlemail.com> said:
>> -= Pure function + invariant data is required for FP =-
>
> That sounds reasonable, though it should really say /transitive/
> invariant data.
Hum, I'm wondering if an invariant class couldn't have a mutable
member, but access to the mutable member from a const or invariant
reference would require synchronized access to keep thread safety
guaranties.
In other words:
class X {
mutable int a;
const void foo() {
writefln(a); // illegal, const this doesn't give access to mutable member.
synchronized (this) {
writefln(a); // legal, synchronization gives access to mutable member.
++a; // legal since a is mutable.
}
}
}
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list