shared - i need it to be useful
Erik van Velzen
erik at evanv.nl
Thu Oct 18 19:51:17 UTC 2018
On Thursday, 18 October 2018 at 19:26:39 UTC, Stanislav Blinov
wrote:
> On Thursday, 18 October 2018 at 19:04:58 UTC, Erik van Velzen
> wrote:
>> On Thursday, 18 October 2018 at 17:47:29 UTC, Stanislav Blinov
>> wrote:
>>>
>>> Doesn't work. No matter what you show Manu or Simen here they
>>> think it's just a bad contrived example. You can't sway them
>>> by the fact that the compiler currently *prevents* this from
>>> happening.
>>
>> Manu said clearly that the receiving thread won't be able to
>> read or write the pointer.
>
> Yes it will, by casting `shared` away. *Just like* his proposed
> "wrap everything into" struct will. There's exactly no
> difference.
>
Casting is inherently unsafe. Or at least, there's no threadsafe
guarantee.
>> Because int or int* does not have threadsafe member functions.
>
> int doesn't have any member functions. Or it can have as many
> as you like per UFCS. Same goes for structs. Because "methods"
> are just free functions in disguise, so that whole distinction
> in Manu's proposal is a weaksauce convention at best.
>
>> You can still disagree on the merits, but so far it has been
>> demonstrated as a sound idea.
>
> No, it hasn't been.
I think you are missing the wider point. I can write
thread-unsafe code *right now*, no casts required. Just put
shared at the declaration. The proposal would actually give some
guarantees.
More information about the Digitalmars-d
mailing list