Adding a new design constraint to D
FeepingCreature
feepingcreature at gmail.com
Mon Jun 20 09:27:59 UTC 2022
On Saturday, 18 June 2022 at 18:02:08 UTC, Max Samukha wrote:
> On Saturday, 18 June 2022 at 08:04:55 UTC, FeepingCreature
> wrote:
>
>> a function in a module is "on the same level" as a method in
>> the class.
>
> If it is on the same level, then I would expect 'foo' below to
> lock the mutex and run the invariant check:
>
> ```d
> synchronized class C
> {
> private int x;
> private int y = 1;
>
> invariant() { assert(y == x + 1); }
> }
>
> void foo(C c, int x)
> {
> c.x = x;
> c.y = x + 1;
> }
> ```
And on reflection, I think I agree that it should.
More information about the Digitalmars-d
mailing list