Hacker News new | ask | show | jobs
by 52-6F-62 3101 days ago
It would be a little more accurate to say that in D, memory safety is optional.

If you wrote every method using the @safe flag, you'd be forced to write a memory-safe program. Eg:

    void main() @safe
    {
      int everything = 42;
      int* theAnswer = &a;
      int* earth     = theAnswer * 2; // Won't compile. 
    }
With no flag or @system, safety is not ensured. Using @trusted will allow a function to be called, safe or not, from other safe functions ending the safety. But by design @safe functions can only call other @safe functions.