On 8/26/20 10:29 AM, Dukc wrote:
On Sunday, 23 August 2020 at 19:39:35 UTC, Paul Backus wrote:
https://pbackus.github.io/blog/how-does-memory-safety-work-in-d.html

What exactly do we mean when we talk about "memory safety" in D? Is it the same thing as "undefined behavior"? Is it ever correct to mark and `extern(C)` function as `@trusted`? This post is my attempt to understand, and answer, questions like these.

If you think I've gotten anything wrong, please leave a reply--this is definitely an area where I'm still learning.

Good post.

I think there is a workaround to the variable access being always safe. Something like this in a dedicated module:

```
struct SystemVar(T, bool safeVal)
{  private T _var;
    static if (safeVal) @safe pure nothrow @nogc auto val()
    {  return _var;
    }
    else pure nothrow @nogc auto val(){return _var;}
    pure nothrow @nogc ref var(){return _var;}
}
```


Nice idea. You need to mark everything as @system that should be -- this is a template, so the compiler is going to happily mark a lot (all?) of that as @safe.

-Steve

Reply via email to