Temporally safe by default
Dukc
ajieskola at gmail.com
Fri Apr 5 09:11:51 UTC 2024
On Thursday, 4 April 2024 at 12:42:07 UTC, Richard (Rikki) Andrew
Cattermole wrote:
> On 05/04/2024 1:32 AM, Dukc wrote:
>> On Thursday, 4 April 2024 at 06:45:44 UTC, Richard (Rikki)
>> Andrew Cattermole wrote:
>>
>>>> Can you please write a code example or two? Doesn't have to
>>>> be anything with a nailed-down syntax, but it's really hard
>>>> to be sure what you're suggesting without one.
>>>
>>> Okay so you need something a bit bigger picture for
>>> temporally safe?
>>>
>>> My way of working would mean I would need to solve isolated
>>> and then temporally safe before I can do that.
>>>
>>> It might be a while before it all comes together for me to be
>>> able to do it concretely.
>>
>> I mean, given you're posting this as a new thread in the DIP
>> ideas forum, I'm assuming you have a language improvement idea
>> to present and want some informal feedback for it. But I don't
>> get from your posts what exactly you're proposing, only that
>> it's some sort of improvement to `@safe`.
>
> Okay yes, you want some big picture overview.
Thanks.
>
> Temporal safety is about making sure one thread doesn't stomp
> all over memory that another thread also knows about.
>
> So this is locking, ensuring only one thread has a reference to
> it, atomics ext.
>
> Moving us over to this without the edition system would break
> everyone's code. So it has to be based upon this.
>
> So the question of this thread is all about how do we annotate
> our code to indicate its temporally safe and how does it map
> into older editions view of what safe is. There is at least
> three different solutions to this that I have come up with.
Isn't `shared` just for this? As far as I can tell, you can
define a data structure struct that, when `shared`, allows
multiple threads to access it, works from 100% `@safe` client
code and doesn't allow any data races to happen.
Of course, actually implementing the data structure is
challenging, just as it is for a dip1000-using reference counted
data structure.
More information about the dip.ideas
mailing list