Adding a new design constraint to D

deadalnix deadalnix at gmail.com
Sat Jun 18 21:13:07 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;
> }
> ```

If the argument is that synchronized and invariant are messed up, 
yes.


More information about the Digitalmars-d mailing list