`shared`...
Nicholas Wilson
iamthewilsonator at hotmail.com
Mon Oct 1 10:15:43 UTC 2018
On Monday, 1 October 2018 at 09:55:41 UTC, ag0aep6g wrote:
> On 10/01/2018 08:47 AM, Nicholas Wilson wrote:
>> In order to be safe, a mutable parameter can be implicitly
>> cast to shared iff the parameter is also scope (that includes
>> the `this` reference`). With an implicit cast in place of the
>> explicit cast under the new rules it would fail to compile
>> because the `this` reference is not scope.
>
> I don't see why it would fail to compile. There's no reason why
> my `doThing` couldn't be marked as `scope`. It doesn't leak
> anything.
Hmm, you are right. Its annoying because the use case for this is
where the data is already shared and a lock has been taken.
> `pure` would break the example. I'm not sure if it would ensure
> safety, though. Can a `pure` method spawn a new thread (that
> outlives the method call)?
Error: pure function onlineapp.f cannot call impure function
core.thread.Thread.start
More information about the Digitalmars-d
mailing list