shared - i need it to be useful

Stanislav Blinov stanislav.blinov at gmail.com
Sun Oct 21 13:24:49 UTC 2018


On Sunday, 21 October 2018 at 11:25:16 UTC, aliak wrote:
> On Saturday, 20 October 2018 at 16:41:41 UTC, Stanislav Blinov 
> wrote:
>> Those are not "ok". They're only "ok" under Manu's proposal so 
>> long as the author of C promises (via documentation) that 
>> that's indeed "ok". There can be no statically-enforced 
>> guarantees that those calls are "ok", or that issuing them in 
>> that order is "ok". Yet Manu keeps insisting that somehow 
>> there is.
>
> No he is not insisting you can statically enforce thread safety.

I stand corrected, it would seem so.

> When I say ok, I mean assuming the implementer actually wrote 
> correct code. This applies to any shared method today as well.

This ("ok") can only be achieved if the "implementor" (the 
"expert") writes every function self-contained, at which point 
sharing something from user code becomes a non-issue (i.e. it 
becomes unnecessary). But that's not a very useful API. As soon 
as you have more than one function operating on the same data, 
the onus is on the user (the caller) to call those functions in 
correct order, or, more generally, without invalidating the state 
of shared data.


More information about the Digitalmars-d mailing list