Blog Post: What Does Memory Safety Really Mean in D?

Dukc ajieskola at gmail.com
Wed Aug 26 14:29:46 UTC 2020


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;}
}
```



More information about the Digitalmars-d-announce mailing list