shared - i need it to be useful

Steven Schveighoffer schveiguy at gmail.com
Tue Oct 16 13:33:50 UTC 2018


On 10/16/18 9:25 AM, Steven Schveighoffer wrote:
> On 10/15/18 2:46 PM, Manu wrote:

>>> From there, it opens up another critical opportunity; T* -> shared(T)*
>> promotion.
>> Const would be useless without T* -> const(T)* promotion. Shared
>> suffers a similar problem.
>> If you write a lock-free queue for instance, and all the methods are
>> `shared` (ie, threadsafe), then under the current rules, you can't
>> interact with the object when it's not shared, and that's fairly
>> useless.
>>

Oh, I didn't see this part. Completely agree with Timon on this, no 
implicit conversions should be allowed.

If you want to have a lock-free implementation of something, you can 
abstract the assignments and reads behind the proper mechanisms anyway, 
and still avoid locking (casting is not locking).

-Steve


More information about the Digitalmars-d mailing list