D1.5 anyone?
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Wed Apr 12 07:38:00 UTC 2023
On 12/04/2023 7:27 PM, Walter Bright wrote:
> On 4/12/2023 12:11 AM, Richard (Rikki) Andrew Cattermole wrote:
>> Unless proven otherwise, all memory is owned by the process not the
>> thread and therefore is the default.
>
> Let's see if I understand:
>
> int abc(int* p);
>
> int sum(int[] a)
> {
> int sum = 0;
> abc(&sum);
> for (int i = 0; i < a.length; ++i)
> sum += a[i];
> return sum;
> }
>
> Your position is that `i` and `sum` should be shared variables? What if
> `abc(&sum)` passes `&sum` to a concurrent thread?
No, you have that backwards.
In both of those cases its owned by the thread. With @safe they would be
scope, which is a partial implementation of 'owned by thread' checking.
A better example would be `a`. This is an argument, with an unknown
memory lifetime or ownership, that should be shared implicitly even if
it was marked scope.
More information about the Digitalmars-d
mailing list